{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "initial_id",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T03:53:36.974681Z",
     "start_time": "2024-04-01T03:53:36.645929Z"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import requests\n",
    "from tqdm import tqdm\n",
    "import pymysql\n",
    "import pandas as pd\n",
    "import requests\n",
    "from tqdm import tqdm\n",
    "from urllib.parse import urlparse\n",
    "import sys\n",
    "\n",
    "from sqlalchemy import create_engine\n",
    "from datetime import datetime,date\n",
    "import json\n",
    "tqdm.pandas()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8c00b89a7d5f74a9",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T03:53:37.810825Z",
     "start_time": "2024-04-01T03:53:37.801552Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Successfully connected to the mysql:47.253.56.86/4001\n"
     ]
    }
   ],
   "source": [
    "def mysql_engine(host, port, user, passwd, db=None):\n",
    "    try:\n",
    "        engine = create_engine(f'mysql+pymysql://{user}:{passwd}@{host}:{port}/{db}')\n",
    "        print(\"Successfully connected to the mysql:{}/{}\".format(host,port))\n",
    "        return engine\n",
    "    except Exception as e:\n",
    "        print(f\"An error occurred: {e}\")\n",
    "mysql_rule = mysql_engine('47.253.56.86',4001,'longxiaolei','WWsCQ9TXG+BJBHlK','rule')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7e6e340a9b36a67a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-21T08:05:33.694763Z",
     "start_time": "2024-03-21T08:05:33.684821Z"
    },
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class Kit(object):\n",
    "    \"\"\"\n",
    "    常用工具类\n",
    "    \"\"\"\n",
    "\n",
    "    def __init__(self, positive_label=1, negative_label=0):\n",
    "        self.positive_label = positive_label\n",
    "        self.negative_label = negative_label\n",
    "        pass\n",
    "\n",
    "    def univerate(self, df, var_name, target, lamb=0.001, retWoeDict=False):\n",
    "        \"\"\"\n",
    "        单变量分析函数，目前支持的计算指标为 IV,KS,LIFT\n",
    "        建议用于编码后的数值型变量进行分析,若在前面使用了cond_insert方法调整了cond\n",
    "        \"\"\"\n",
    "        dti = pd.crosstab(df[var_name], df[target])\n",
    "        # dti = df.groupby([var_name, target])[target].count().unstack().fillna(0)\n",
    "        dti.rename({self.positive_label: \"positive\", self.negative_label: \"negative\"}, axis=1, inplace=True)\n",
    "        dti[\"positive\"] = dti[\"positive\"].astype(int)\n",
    "        dti[\"negative\"] = dti[\"negative\"].astype(int)\n",
    "        p_t = dti[\"positive\"].sum()\n",
    "        n_t = dti[\"negative\"].sum()\n",
    "        t_t = p_t + n_t\n",
    "        r_t = p_t / t_t\n",
    "        dti[\"total\"] = dti[\"positive\"] + dti[\"negative\"]\n",
    "        dti[\"total_rate\"] = dti[\"total\"] / t_t\n",
    "        dti[\"positive_rate\"] = dti[\"positive\"] / dti[\"total\"]  # (rs[\"positive\"] + rs[\"negative\"])\n",
    "        dti[\"negative_cum\"] = dti[\"negative\"].cumsum()\n",
    "        dti[\"positive_cum\"] = dti[\"positive\"].cumsum()\n",
    "        dti[\"woe\"] = np.log(((dti[\"negative\"] / n_t) + lamb) / ((dti[\"positive\"] / p_t) + lamb))\n",
    "        dti[\"LIFT\"] = dti[\"positive_rate\"] / r_t\n",
    "        dti[\"KS\"] = np.abs((dti[\"positive_cum\"] / p_t) - (dti[\"negative_cum\"] / n_t))\n",
    "        dti[\"IV\"] = (dti[\"negative\"] / n_t - dti[\"positive\"] / p_t) * dti['woe']\n",
    "        IV = dti[\"IV\"].sum()\n",
    "        KS = dti[\"KS\"].max()\n",
    "        dti[\"IV\"] = IV\n",
    "        # dti[\"KS\"] = KS\n",
    "        dti = dti.reset_index()\n",
    "        dti.columns.name = None\n",
    "        dti.rename({\"Total\": \"num\", var_name: \"bin\"}, axis=1, inplace=True)\n",
    "        dti.insert(0, \"target\", [target] * dti.shape[0])\n",
    "        dti.insert(0, \"var\", [var_name] * dti.shape[0])\n",
    "        if retWoeDict:\n",
    "            if isinstance(dti[\"bin\"].dtype, pd.core.dtypes.dtypes.CategoricalDtype):\n",
    "                dti[\"v\"] = dti[\"bin\"].map(lambda x: x.right)\n",
    "            else:\n",
    "                dti[\"v\"] = dti[\"bin\"]\n",
    "            woeDict = pd.Series(dti[\"woe\"].values, index=dti[\"v\"].values).to_dict()\n",
    "            dti.drop(columns=[\"negative_cum\", \"positive_cum\", \"v\"], inplace=True)\n",
    "            return dti, woeDict\n",
    "        dti.drop(columns=[\"negative_cum\", \"positive_cum\"], inplace=True)\n",
    "        return dti\n",
    "\n",
    "\n",
    "    def group_rs(self, data, group, sum_col=[], count_col=[], rate_tupes=[]):\n",
    "        \"\"\"\n",
    "        业务分析工具类，同时对比计算多个target指标，查看结果\n",
    "        data : 数据集\n",
    "        sum_col : 需要group_sum的列\n",
    "        count_col : 需要group_count的列\n",
    "        rate_tupe : 需要除法计算的列 格式为 (字段1，字段2，新列名称) 或者 (字段，新列名称)\n",
    "        \"\"\"\n",
    "        grouped = data.groupby(group)\n",
    "        if sum_col is not None and len(sum_col) > 0:\n",
    "            grouped_sum = grouped[sum_col].sum()\n",
    "        if count_col is not None and len(count_col) > 0:\n",
    "            grouped_count = grouped[count_col].count()\n",
    "            grouped = pd.concat([grouped_count, grouped_sum], axis=1)\n",
    "        else:\n",
    "            grouped = grouped_sum\n",
    "\n",
    "        for tup in rate_tupes:\n",
    "            size = len(tup)\n",
    "            if size == 3:\n",
    "                grouped[tup[2]] = grouped[tup[0]] / grouped[tup[1]]\n",
    "            if size == 2:\n",
    "                grouped[tup[1]] = grouped[tup[0]] / grouped[tup[0]].sum()\n",
    "        return grouped.reset_index()\n",
    "\n",
    "kit = Kit()\n",
    "\n",
    "def set_pd_show(max_rows=500, max_columns=200, max_colwidth=70):\n",
    "    import pandas as pd\n",
    "    pd.set_option(\"display.max_rows\", max_rows)\n",
    "    pd.set_option(\"display.max_columns\", max_columns)\n",
    "    pd.set_option(\"display.max_colwidth\", max_colwidth)\n",
    "set_pd_show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8c7395f9a0af94b2",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "# 模型贷后监控"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "35ed3c45",
   "metadata": {},
   "source": [
    "## 加载urule的字段数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "dde27ca4",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-21T08:06:01.709092Z",
     "start_time": "2024-03-21T08:05:42.459412Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load 570 file,data shape (310372, 8)\n",
      "(310372, 8)\n",
      "已经完成urule日志的加载: 2024-03-25 12:00:14\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "import os\n",
    "import pandas as pd\n",
    "def files_of_dir(dir_path:str, contains_str=\"\",start_date=None):\n",
    "    file_paths = []\n",
    "    if start_date is None:\n",
    "        for file_name in os.listdir(dir_path):\n",
    "             if contains_str in file_name:\n",
    "                    file_paths.append(os.path.join(dir_path, file_name))\n",
    "    else:\n",
    "        for file_name in os.listdir(dir_path):\n",
    "            if (contains_str in file_name) & ( any( file_type in file_name for file_type in ['.parquet','.pickle','.txt','.csv','.xlsx'] ) ):\n",
    "                pattern = r\"\\d{4}-\\d{2}-\\d{2}\" \n",
    "                match = re.search(pattern, file_name)\n",
    "                date = match.group()\n",
    "                if date>= start_date:\n",
    "                    file_paths.append(os.path.join(dir_path, file_name))\n",
    "    file_paths.sort()\n",
    "    return file_paths\n",
    "def batch_load_parquet_files(paths):\n",
    "    df_list = []\n",
    "    for file_path in paths:\n",
    "        df = pd.read_parquet(file_path)\n",
    "        df_list.append(df)\n",
    "    df_new = pd.concat(df_list).reset_index(drop=True)\n",
    "    print(f\"load {len(paths)} file,data shape {df_new.shape}\")\n",
    "    return df_new\n",
    "urule_log_dir = '/home/loong/jupyter/YuChuang/urule_log/data'\n",
    "urule_log_paths = files_of_dir(urule_log_dir,\"type1\",'2023-11-22')\n",
    "urule_log_df = batch_load_parquet_files(urule_log_paths)\n",
    "print(urule_log_df.shape)\n",
    "print(\"已经完成urule日志的加载:\",urule_log_df['create_time'].max())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "514b8df2",
   "metadata": {},
   "source": [
    "## 加载贷后信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "62fd06633551efa3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-21T08:07:20.986268Z",
     "start_time": "2024-03-21T08:06:52.798163Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(210513, 13)\n",
      "当前可观测最晚订单的申请时间: 2024-03-19 00:21:37\n",
      "当前可观测最晚订单的还款时间: 2024-03-24\n",
      "表连接后: (198890, 15)\n"
     ]
    }
   ],
   "source": [
    "loan_sql = \"\"\"\n",
    "select\n",
    "      l.merchant_id,\n",
    "      l.tx_id,\n",
    "      l.acq_channel,\n",
    "       l.phone_number,\n",
    "       l.app_order_id,\n",
    "       l.device_type,\n",
    "       l.new_old_user_status,\n",
    "       l.repayment_date,\n",
    "       l.apply_time,\n",
    "       l.def_pd1,\n",
    "       l.agr_pd1,\n",
    "       l.def_cpd,\n",
    "       l.agr_cpd\n",
    "from rule.loan_v l where  merchant_id in ('AC', 'AM','AL','AG') and  l.agr_pd1=1\n",
    " and l.tx_id is not null\n",
    " and l.apply_time >= '2023-11-12'  -- and weekofyear(repayment_date)>=48 \n",
    "\"\"\"\n",
    "loan_df = pd.read_sql(loan_sql,mysql_rule)\n",
    "print(loan_df.shape)\n",
    "print(\"当前可观测最晚订单的申请时间:\",loan_df['apply_time'].max())\n",
    "print(\"当前可观测最晚订单的还款时间:\",loan_df['repayment_date'].max())\n",
    "\n",
    "from datetime import datetime,timedelta\n",
    "def format_date2week(date_obj):\n",
    "    from datetime import datetime\n",
    "    weekday = date_obj.weekday()\n",
    "    start_of_week = date_obj - timedelta(days=weekday)\n",
    "    end_of_week = start_of_week + timedelta(days=6)\n",
    "    monday = start_of_week.strftime('%m.%d')\n",
    "    year = start_of_week.year\n",
    "    sunday = end_of_week.strftime('%m.%d')\n",
    "    return f'{year}.{monday}~{sunday}'\n",
    "\n",
    "loan_df['repayment_week'] = pd.to_datetime(loan_df['repayment_date']).map(format_date2week)\n",
    "\n",
    "urule_log_df['tx_id'] = urule_log_df['tx_id'].astype(str)\n",
    "loan_df['tx_id'] = loan_df['tx_id'].astype(str)\n",
    "df = urule_log_df[['merchant_id','tx_id','req_data']].merge(loan_df,on=['merchant_id','tx_id']) \n",
    "print(\"表连接后:\",df.shape)\n",
    "# del urule_log_df\n",
    "# del loan_df\n",
    "# import gc\n",
    "# gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ff76c53ed081bcb2",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-21T08:08:05.186931Z",
     "start_time": "2024-03-21T08:07:28.240764Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "已经完成时间时间的转换 2024-03-19 00:21:37 2024.03.18~03.24\n"
     ]
    }
   ],
   "source": [
    "# def get_filed(json_str,filed_name):\n",
    "#     import json\n",
    "#     try:\n",
    "#         obj = json.loads(json_str)\n",
    "#         return obj[filed_name]\n",
    "#     except Exception as e:\n",
    "#         return None\n",
    "# df['modelScoreParams_scoreV1']= df['req_data'].map(lambda x : get_filed(x,'modelScoreParams_scoreV1')).astype(float)\n",
    "# df['modelScoreParams_scoreV2']= df['req_data'].map(lambda x : get_filed(x,'modelScoreParams_scoreV2')).astype(float)\n",
    "# df['modelScoreParams_scoreV3']= df['req_data'].map(lambda x : get_filed(x,'modelScoreParams_scoreV3')).astype(float)\n",
    "# df['modelScoreParams_scoreV4']= df['req_data'].map(lambda x : get_filed(x,'modelScoreParams_scoreV4')).astype(float)\n",
    "# df['modelScoreParams_scoreV5']= df['req_data'].map(lambda x : get_filed(x,'modelScoreParams_scoreV5')).astype(float)\n",
    "# df['modelScoreParams_scoreV6']= df['req_data'].map(lambda x : get_filed(x,'modelScoreParams_scoreV6')).astype(float)\n",
    "# df['modelScoreParams_scoreV7']= df['req_data'].map(lambda x : get_filed(x,'modelScoreParams_scoreV7')).astype(float)\n",
    "# df['modelScoreParams_scoreV8']= df['req_data'].map(lambda x : get_filed(x,'modelScoreParams_scoreV8')).astype(float)\n",
    "# df['modelScoreParams_scoreV9']= df['req_data'].map(lambda x : get_filed(x,'modelScoreParams_scoreV9')).astype(float)\n",
    "\n",
    "def search_json(json_str,query):\n",
    "    import json\n",
    "    obj = json.loads(json_str)\n",
    "    return query_dict(obj,query)\n",
    "def query_dict(data, query):\n",
    "    keys = query.strip(\"$.\").split(\".\")\n",
    "    result = data\n",
    "    for key in keys:\n",
    "        if isinstance(result, dict) and key in result:\n",
    "            result = result[key]\n",
    "        else:\n",
    "            return None\n",
    "    return result\n",
    "def query_json(json_str,querys):\n",
    "    import json\n",
    "    obj = json.loads(json_str)\n",
    "    if isinstance(querys,str) and len(querys)>0:\n",
    "        return query_dict(obj,querys)\n",
    "    if isinstance(querys,list) and len(querys)>0:\n",
    "        result_arr = []\n",
    "        for query in querys:\n",
    "            result_arr.append(query_dict(obj,query))\n",
    "        return tuple(result_arr)\n",
    "\n",
    "columns = ['modelScoreParams_scoreV1','modelScoreParams_scoreV2','modelScoreParams_scoreV3','modelScoreParams_scoreV4','modelScoreParams_scoreV5',\n",
    "           'modelScoreParams_scoreV6','modelScoreParams_scoreV7','modelScoreParams_scoreV8','modelScoreParams_scoreV9','modelScoreParams_scoreV10','modelScoreParams_scoreV11','modelScoreParams_scoreV12','modelScoreParams_scoreV13']\n",
    "df[columns] = df.apply(lambda x : query_json(x['req_data'],columns),axis=1,result_type='expand')\n",
    "df[columns] = df[columns].astype(float)\n",
    "\n",
    "df = df.rename(columns={\n",
    "    'modelScoreParams_scoreV1':'scorev1',\n",
    "    'modelScoreParams_scoreV2':'scorev2',\n",
    "    'modelScoreParams_scoreV3':'scorev3',\n",
    "    'modelScoreParams_scoreV4':'scorev4',\n",
    "    'modelScoreParams_scoreV5':'scorev5',\n",
    "    'modelScoreParams_scoreV6':'scorev6',\n",
    "    'modelScoreParams_scoreV7':'scorev7',\n",
    "    'modelScoreParams_scoreV8':'scorev8',\n",
    "    'modelScoreParams_scoreV9':'scorev9',\n",
    "    'modelScoreParams_scoreV10':'scorev10',\n",
    "    'modelScoreParams_scoreV11':'scorev11',\n",
    "    'modelScoreParams_scoreV12':'scorev12',\n",
    "    'modelScoreParams_scoreV13':'scorev13',\n",
    "\n",
    "})\n",
    "\n",
    "def def_pd1_aclc(row):\n",
    "    if row['agr_pd1'] ==1 :\n",
    "        if row['def_pd1'] ==1 :\n",
    "            return 1\n",
    "        else:\n",
    "            return 0\n",
    "    else :\n",
    "        return None\n",
    "def def_cpd_aclc(row):\n",
    "    if row['agr_cpd'] ==1 :\n",
    "        if row['def_cpd'] ==1 :\n",
    "            return 1\n",
    "        else:\n",
    "            return 0\n",
    "    else :\n",
    "        return None\n",
    "df['def_pd1'] = df.apply(def_pd1_aclc,axis=1)\n",
    "df['def_cpd'] = df.apply(def_cpd_aclc,axis=1)\n",
    "\n",
    "df.repayment_date = pd.to_datetime(df.repayment_date)\n",
    "print(\"已经完成时间时间的转换\",df['apply_time'].max(),df['repayment_week'].max())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a85533ba9bf68037",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "# scorev1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "751f7137eff613cc",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-21T08:08:12.086982Z",
     "start_time": "2024-03-21T08:08:12.027042Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>203</td>\n",
       "      <td>238</td>\n",
       "      <td>441</td>\n",
       "      <td>0.028211</td>\n",
       "      <td>0.539683</td>\n",
       "      <td>-0.369480</td>\n",
       "      <td>1.214558</td>\n",
       "      <td>0.010893</td>\n",
       "      <td>0.037719</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>1857</td>\n",
       "      <td>1765</td>\n",
       "      <td>3622</td>\n",
       "      <td>0.231704</td>\n",
       "      <td>0.487300</td>\n",
       "      <td>-0.171996</td>\n",
       "      <td>1.096670</td>\n",
       "      <td>0.051204</td>\n",
       "      <td>0.037719</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>2031</td>\n",
       "      <td>1797</td>\n",
       "      <td>3828</td>\n",
       "      <td>0.244882</td>\n",
       "      <td>0.469436</td>\n",
       "      <td>-0.100727</td>\n",
       "      <td>1.056467</td>\n",
       "      <td>0.076090</td>\n",
       "      <td>0.037719</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>3458</td>\n",
       "      <td>2574</td>\n",
       "      <td>6032</td>\n",
       "      <td>0.385875</td>\n",
       "      <td>0.426724</td>\n",
       "      <td>0.071497</td>\n",
       "      <td>0.960344</td>\n",
       "      <td>0.048551</td>\n",
       "      <td>0.037719</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>1137</td>\n",
       "      <td>572</td>\n",
       "      <td>1709</td>\n",
       "      <td>0.109327</td>\n",
       "      <td>0.334699</td>\n",
       "      <td>0.459003</td>\n",
       "      <td>0.753241</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.037719</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev1_bin  def_pd1   (-inf, 480.0]       203       238    441   \n",
       "1  scorev1_bin  def_pd1  (480.0, 520.0]      1857      1765   3622   \n",
       "2  scorev1_bin  def_pd1  (520.0, 540.0]      2031      1797   3828   \n",
       "3  scorev1_bin  def_pd1  (540.0, 580.0]      3458      2574   6032   \n",
       "4  scorev1_bin  def_pd1    (580.0, inf]      1137       572   1709   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.028211       0.539683 -0.369480  1.214558  0.010893  0.037719  \n",
       "1    0.231704       0.487300 -0.171996  1.096670  0.051204  0.037719  \n",
       "2    0.244882       0.469436 -0.100727  1.056467  0.076090  0.037719  \n",
       "3    0.385875       0.426724  0.071497  0.960344  0.048551  0.037719  \n",
       "4    0.109327       0.334699  0.459003  0.753241  0.000000  0.037719  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition  = (df.merchant_id=='AM') & (df.device_type ==\"android\") & (df.new_old_user_status== 0 ) & (df.scorev1>0) & (df.repayment_date>=pd.to_datetime('2023-11-27'))\n",
    "df['scorev1_bin'] = pd.cut(df['scorev1'],[-np.inf,480,520,540,580,np.inf])\n",
    "kit.univerate(df[condition],'scorev1_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "a2272536d7a4996c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-21T08:08:13.197037Z",
     "start_time": "2024-03-21T08:08:13.150114Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>226</td>\n",
       "      <td>246</td>\n",
       "      <td>472</td>\n",
       "      <td>0.028447</td>\n",
       "      <td>0.521186</td>\n",
       "      <td>-0.361034</td>\n",
       "      <td>1.216933</td>\n",
       "      <td>0.010794</td>\n",
       "      <td>0.05894</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>1243</td>\n",
       "      <td>1348</td>\n",
       "      <td>2591</td>\n",
       "      <td>0.156160</td>\n",
       "      <td>0.520262</td>\n",
       "      <td>-0.367627</td>\n",
       "      <td>1.214775</td>\n",
       "      <td>0.069458</td>\n",
       "      <td>0.05894</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>1313</td>\n",
       "      <td>1229</td>\n",
       "      <td>2542</td>\n",
       "      <td>0.153206</td>\n",
       "      <td>0.483478</td>\n",
       "      <td>-0.221330</td>\n",
       "      <td>1.128885</td>\n",
       "      <td>0.103996</td>\n",
       "      <td>0.05894</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>4444</td>\n",
       "      <td>3076</td>\n",
       "      <td>7520</td>\n",
       "      <td>0.453230</td>\n",
       "      <td>0.409043</td>\n",
       "      <td>0.078872</td>\n",
       "      <td>0.955085</td>\n",
       "      <td>0.068389</td>\n",
       "      <td>0.05894</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>2260</td>\n",
       "      <td>1207</td>\n",
       "      <td>3467</td>\n",
       "      <td>0.208956</td>\n",
       "      <td>0.348140</td>\n",
       "      <td>0.336668</td>\n",
       "      <td>0.812881</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.05894</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev1_bin  def_pd1   (-inf, 480.0]       226       246    472   \n",
       "1  scorev1_bin  def_pd1  (480.0, 520.0]      1243      1348   2591   \n",
       "2  scorev1_bin  def_pd1  (520.0, 540.0]      1313      1229   2542   \n",
       "3  scorev1_bin  def_pd1  (540.0, 580.0]      4444      3076   7520   \n",
       "4  scorev1_bin  def_pd1    (580.0, inf]      2260      1207   3467   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS       IV  \n",
       "0    0.028447       0.521186 -0.361034  1.216933  0.010794  0.05894  \n",
       "1    0.156160       0.520262 -0.367627  1.214775  0.069458  0.05894  \n",
       "2    0.153206       0.483478 -0.221330  1.128885  0.103996  0.05894  \n",
       "3    0.453230       0.409043  0.078872  0.955085  0.068389  0.05894  \n",
       "4    0.208956       0.348140  0.336668  0.812881  0.000000  0.05894  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition  = (df.merchant_id=='AM') & (df.device_type ==\"android\") & (df.new_old_user_status== 1 ) & (df.scorev1>0) & (df.repayment_date>=pd.to_datetime('2023-11-27'))\n",
    "df['scorev1_bin'] = pd.cut(df['scorev1'],[-np.inf,480,520,540,580,np.inf])\n",
    "kit.univerate(df[condition],'scorev1_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "461f0aeb30791e25",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-21T08:08:14.068887Z",
     "start_time": "2024-03-21T08:08:14.026947Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>175</td>\n",
       "      <td>249</td>\n",
       "      <td>424</td>\n",
       "      <td>0.032285</td>\n",
       "      <td>0.587264</td>\n",
       "      <td>-0.530341</td>\n",
       "      <td>1.300597</td>\n",
       "      <td>0.017694</td>\n",
       "      <td>0.050333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>1199</td>\n",
       "      <td>1290</td>\n",
       "      <td>2489</td>\n",
       "      <td>0.189523</td>\n",
       "      <td>0.518280</td>\n",
       "      <td>-0.266225</td>\n",
       "      <td>1.147821</td>\n",
       "      <td>0.068774</td>\n",
       "      <td>0.050333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>1197</td>\n",
       "      <td>1161</td>\n",
       "      <td>2358</td>\n",
       "      <td>0.179548</td>\n",
       "      <td>0.492366</td>\n",
       "      <td>-0.163032</td>\n",
       "      <td>1.090430</td>\n",
       "      <td>0.098377</td>\n",
       "      <td>0.050333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>3115</td>\n",
       "      <td>2325</td>\n",
       "      <td>5440</td>\n",
       "      <td>0.414224</td>\n",
       "      <td>0.427390</td>\n",
       "      <td>0.097798</td>\n",
       "      <td>0.946528</td>\n",
       "      <td>0.057993</td>\n",
       "      <td>0.050333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>scorev1_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>1517</td>\n",
       "      <td>905</td>\n",
       "      <td>2422</td>\n",
       "      <td>0.184421</td>\n",
       "      <td>0.373658</td>\n",
       "      <td>0.320287</td>\n",
       "      <td>0.827530</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.050333</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev1_bin  def_pd1   (-inf, 480.0]       175       249    424   \n",
       "1  scorev1_bin  def_pd1  (480.0, 520.0]      1199      1290   2489   \n",
       "2  scorev1_bin  def_pd1  (520.0, 540.0]      1197      1161   2358   \n",
       "3  scorev1_bin  def_pd1  (540.0, 580.0]      3115      2325   5440   \n",
       "4  scorev1_bin  def_pd1    (580.0, inf]      1517       905   2422   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.032285       0.587264 -0.530341  1.300597  0.017694  0.050333  \n",
       "1    0.189523       0.518280 -0.266225  1.147821  0.068774  0.050333  \n",
       "2    0.179548       0.492366 -0.163032  1.090430  0.098377  0.050333  \n",
       "3    0.414224       0.427390  0.097798  0.946528  0.057993  0.050333  \n",
       "4    0.184421       0.373658  0.320287  0.827530  0.000000  0.050333  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition  = (df.merchant_id=='AM') & (df.device_type ==\"android\") & (df.new_old_user_status== 2 ) & (df.scorev1>0) & (df.repayment_date>=pd.to_datetime('2023-11-27'))\n",
    "df['scorev1_bin'] = pd.cut(df['scorev1'],[-np.inf,480,520,540,580,np.inf])\n",
    "kit.univerate(df[condition],'scorev1_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f56c969437c799ea",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-21T08:08:19.921525Z",
     "start_time": "2024-03-21T08:08:19.871384Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_367786/218088919.py:63: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.\n",
      "  grouped = data.groupby(group)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>repayment_week</th>\n",
       "      <th>scorev1_bin</th>\n",
       "      <th>def_pd1</th>\n",
       "      <th>agr_pd1</th>\n",
       "      <th>def_cpd</th>\n",
       "      <th>agr_cpd</th>\n",
       "      <th>pd1</th>\n",
       "      <th>cpd</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023.11.27~12.03</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>7</td>\n",
       "      <td>11</td>\n",
       "      <td>7</td>\n",
       "      <td>11</td>\n",
       "      <td>0.636364</td>\n",
       "      <td>0.636364</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2023.11.27~12.03</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>45</td>\n",
       "      <td>75</td>\n",
       "      <td>42</td>\n",
       "      <td>75</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.560000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2023.11.27~12.03</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>32</td>\n",
       "      <td>66</td>\n",
       "      <td>29</td>\n",
       "      <td>66</td>\n",
       "      <td>0.484848</td>\n",
       "      <td>0.439394</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2023.11.27~12.03</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>64</td>\n",
       "      <td>160</td>\n",
       "      <td>62</td>\n",
       "      <td>160</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>0.387500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2023.11.27~12.03</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>11</td>\n",
       "      <td>23</td>\n",
       "      <td>11</td>\n",
       "      <td>23</td>\n",
       "      <td>0.478261</td>\n",
       "      <td>0.478261</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2023.12.04~12.10</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>10</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>21</td>\n",
       "      <td>0.476190</td>\n",
       "      <td>0.476190</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2023.12.04~12.10</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>77</td>\n",
       "      <td>135</td>\n",
       "      <td>77</td>\n",
       "      <td>135</td>\n",
       "      <td>0.570370</td>\n",
       "      <td>0.570370</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2023.12.04~12.10</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>70</td>\n",
       "      <td>141</td>\n",
       "      <td>64</td>\n",
       "      <td>141</td>\n",
       "      <td>0.496454</td>\n",
       "      <td>0.453901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2023.12.04~12.10</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>97</td>\n",
       "      <td>233</td>\n",
       "      <td>91</td>\n",
       "      <td>233</td>\n",
       "      <td>0.416309</td>\n",
       "      <td>0.390558</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2023.12.04~12.10</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>33</td>\n",
       "      <td>88</td>\n",
       "      <td>32</td>\n",
       "      <td>88</td>\n",
       "      <td>0.375000</td>\n",
       "      <td>0.363636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2023.12.11~12.17</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>19</td>\n",
       "      <td>36</td>\n",
       "      <td>16</td>\n",
       "      <td>36</td>\n",
       "      <td>0.527778</td>\n",
       "      <td>0.444444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2023.12.11~12.17</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>58</td>\n",
       "      <td>133</td>\n",
       "      <td>56</td>\n",
       "      <td>133</td>\n",
       "      <td>0.436090</td>\n",
       "      <td>0.421053</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2023.12.11~12.17</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>37</td>\n",
       "      <td>99</td>\n",
       "      <td>32</td>\n",
       "      <td>99</td>\n",
       "      <td>0.373737</td>\n",
       "      <td>0.323232</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2023.12.11~12.17</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>77</td>\n",
       "      <td>207</td>\n",
       "      <td>74</td>\n",
       "      <td>207</td>\n",
       "      <td>0.371981</td>\n",
       "      <td>0.357488</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2023.12.11~12.17</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>23</td>\n",
       "      <td>61</td>\n",
       "      <td>23</td>\n",
       "      <td>61</td>\n",
       "      <td>0.377049</td>\n",
       "      <td>0.377049</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2023.12.18~12.24</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>21</td>\n",
       "      <td>53</td>\n",
       "      <td>21</td>\n",
       "      <td>53</td>\n",
       "      <td>0.396226</td>\n",
       "      <td>0.396226</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2023.12.18~12.24</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>103</td>\n",
       "      <td>245</td>\n",
       "      <td>101</td>\n",
       "      <td>245</td>\n",
       "      <td>0.420408</td>\n",
       "      <td>0.412245</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2023.12.18~12.24</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>83</td>\n",
       "      <td>202</td>\n",
       "      <td>77</td>\n",
       "      <td>202</td>\n",
       "      <td>0.410891</td>\n",
       "      <td>0.381188</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2023.12.18~12.24</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>164</td>\n",
       "      <td>378</td>\n",
       "      <td>155</td>\n",
       "      <td>378</td>\n",
       "      <td>0.433862</td>\n",
       "      <td>0.410053</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2023.12.18~12.24</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>33</td>\n",
       "      <td>93</td>\n",
       "      <td>31</td>\n",
       "      <td>93</td>\n",
       "      <td>0.354839</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>42</td>\n",
       "      <td>57</td>\n",
       "      <td>42</td>\n",
       "      <td>57</td>\n",
       "      <td>0.736842</td>\n",
       "      <td>0.736842</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>74</td>\n",
       "      <td>203</td>\n",
       "      <td>68</td>\n",
       "      <td>203</td>\n",
       "      <td>0.364532</td>\n",
       "      <td>0.334975</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>73</td>\n",
       "      <td>163</td>\n",
       "      <td>67</td>\n",
       "      <td>163</td>\n",
       "      <td>0.447853</td>\n",
       "      <td>0.411043</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>107</td>\n",
       "      <td>262</td>\n",
       "      <td>105</td>\n",
       "      <td>262</td>\n",
       "      <td>0.408397</td>\n",
       "      <td>0.400763</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>40</td>\n",
       "      <td>94</td>\n",
       "      <td>39</td>\n",
       "      <td>94</td>\n",
       "      <td>0.425532</td>\n",
       "      <td>0.414894</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>72</td>\n",
       "      <td>119</td>\n",
       "      <td>68</td>\n",
       "      <td>119</td>\n",
       "      <td>0.605042</td>\n",
       "      <td>0.571429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>290</td>\n",
       "      <td>502</td>\n",
       "      <td>275</td>\n",
       "      <td>502</td>\n",
       "      <td>0.577689</td>\n",
       "      <td>0.547809</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>200</td>\n",
       "      <td>401</td>\n",
       "      <td>192</td>\n",
       "      <td>401</td>\n",
       "      <td>0.498753</td>\n",
       "      <td>0.478803</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>299</td>\n",
       "      <td>697</td>\n",
       "      <td>279</td>\n",
       "      <td>697</td>\n",
       "      <td>0.428981</td>\n",
       "      <td>0.400287</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>82</td>\n",
       "      <td>236</td>\n",
       "      <td>74</td>\n",
       "      <td>236</td>\n",
       "      <td>0.347458</td>\n",
       "      <td>0.313559</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>38</td>\n",
       "      <td>60</td>\n",
       "      <td>36</td>\n",
       "      <td>60</td>\n",
       "      <td>0.633333</td>\n",
       "      <td>0.600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>167</td>\n",
       "      <td>337</td>\n",
       "      <td>161</td>\n",
       "      <td>337</td>\n",
       "      <td>0.495549</td>\n",
       "      <td>0.477745</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>179</td>\n",
       "      <td>344</td>\n",
       "      <td>174</td>\n",
       "      <td>344</td>\n",
       "      <td>0.520349</td>\n",
       "      <td>0.505814</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>300</td>\n",
       "      <td>643</td>\n",
       "      <td>272</td>\n",
       "      <td>643</td>\n",
       "      <td>0.466563</td>\n",
       "      <td>0.423017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>92</td>\n",
       "      <td>278</td>\n",
       "      <td>83</td>\n",
       "      <td>278</td>\n",
       "      <td>0.330935</td>\n",
       "      <td>0.298561</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>27</td>\n",
       "      <td>36</td>\n",
       "      <td>25</td>\n",
       "      <td>36</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>0.694444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>147</td>\n",
       "      <td>292</td>\n",
       "      <td>138</td>\n",
       "      <td>292</td>\n",
       "      <td>0.503425</td>\n",
       "      <td>0.472603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>145</td>\n",
       "      <td>269</td>\n",
       "      <td>138</td>\n",
       "      <td>269</td>\n",
       "      <td>0.539033</td>\n",
       "      <td>0.513011</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>242</td>\n",
       "      <td>552</td>\n",
       "      <td>232</td>\n",
       "      <td>552</td>\n",
       "      <td>0.438406</td>\n",
       "      <td>0.420290</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>96</td>\n",
       "      <td>223</td>\n",
       "      <td>90</td>\n",
       "      <td>223</td>\n",
       "      <td>0.430493</td>\n",
       "      <td>0.403587</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>10</td>\n",
       "      <td>13</td>\n",
       "      <td>10</td>\n",
       "      <td>13</td>\n",
       "      <td>0.769231</td>\n",
       "      <td>0.769231</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>241</td>\n",
       "      <td>402</td>\n",
       "      <td>228</td>\n",
       "      <td>402</td>\n",
       "      <td>0.599502</td>\n",
       "      <td>0.567164</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>232</td>\n",
       "      <td>423</td>\n",
       "      <td>225</td>\n",
       "      <td>423</td>\n",
       "      <td>0.548463</td>\n",
       "      <td>0.531915</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>323</td>\n",
       "      <td>658</td>\n",
       "      <td>298</td>\n",
       "      <td>658</td>\n",
       "      <td>0.490881</td>\n",
       "      <td>0.452888</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>102</td>\n",
       "      <td>226</td>\n",
       "      <td>99</td>\n",
       "      <td>226</td>\n",
       "      <td>0.451327</td>\n",
       "      <td>0.438053</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>70</td>\n",
       "      <td>120</td>\n",
       "      <td>67</td>\n",
       "      <td>120</td>\n",
       "      <td>0.583333</td>\n",
       "      <td>0.558333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>86</td>\n",
       "      <td>179</td>\n",
       "      <td>84</td>\n",
       "      <td>179</td>\n",
       "      <td>0.480447</td>\n",
       "      <td>0.469274</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>165</td>\n",
       "      <td>361</td>\n",
       "      <td>149</td>\n",
       "      <td>361</td>\n",
       "      <td>0.457064</td>\n",
       "      <td>0.412742</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>70</td>\n",
       "      <td>171</td>\n",
       "      <td>66</td>\n",
       "      <td>171</td>\n",
       "      <td>0.409357</td>\n",
       "      <td>0.385965</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>4</td>\n",
       "      <td>10</td>\n",
       "      <td>4</td>\n",
       "      <td>10</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>0.400000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>5</td>\n",
       "      <td>13</td>\n",
       "      <td>5</td>\n",
       "      <td>13</td>\n",
       "      <td>0.384615</td>\n",
       "      <td>0.384615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>74</td>\n",
       "      <td>218</td>\n",
       "      <td>66</td>\n",
       "      <td>218</td>\n",
       "      <td>0.339450</td>\n",
       "      <td>0.302752</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>35</td>\n",
       "      <td>142</td>\n",
       "      <td>28</td>\n",
       "      <td>142</td>\n",
       "      <td>0.246479</td>\n",
       "      <td>0.197183</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>0.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>48</td>\n",
       "      <td>153</td>\n",
       "      <td>41</td>\n",
       "      <td>153</td>\n",
       "      <td>0.313725</td>\n",
       "      <td>0.267974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>42</td>\n",
       "      <td>104</td>\n",
       "      <td>34</td>\n",
       "      <td>104</td>\n",
       "      <td>0.403846</td>\n",
       "      <td>0.326923</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>63</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>54</td>\n",
       "      <td>176</td>\n",
       "      <td>53</td>\n",
       "      <td>176</td>\n",
       "      <td>0.306818</td>\n",
       "      <td>0.301136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>64</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>37</td>\n",
       "      <td>134</td>\n",
       "      <td>26</td>\n",
       "      <td>134</td>\n",
       "      <td>0.276119</td>\n",
       "      <td>0.194030</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>65</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>8</td>\n",
       "      <td>22</td>\n",
       "      <td>6</td>\n",
       "      <td>22</td>\n",
       "      <td>0.363636</td>\n",
       "      <td>0.272727</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>67</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>11</td>\n",
       "      <td>34</td>\n",
       "      <td>11</td>\n",
       "      <td>34</td>\n",
       "      <td>0.323529</td>\n",
       "      <td>0.323529</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>68</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>73</td>\n",
       "      <td>180</td>\n",
       "      <td>70</td>\n",
       "      <td>180</td>\n",
       "      <td>0.405556</td>\n",
       "      <td>0.388889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>69</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>42</td>\n",
       "      <td>125</td>\n",
       "      <td>38</td>\n",
       "      <td>125</td>\n",
       "      <td>0.336000</td>\n",
       "      <td>0.304000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>71</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "      <td>8</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>0.125000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>73</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>84</td>\n",
       "      <td>221</td>\n",
       "      <td>78</td>\n",
       "      <td>221</td>\n",
       "      <td>0.380090</td>\n",
       "      <td>0.352941</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>59</td>\n",
       "      <td>124</td>\n",
       "      <td>58</td>\n",
       "      <td>124</td>\n",
       "      <td>0.475806</td>\n",
       "      <td>0.467742</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>76</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>77</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>68</td>\n",
       "      <td>182</td>\n",
       "      <td>64</td>\n",
       "      <td>182</td>\n",
       "      <td>0.373626</td>\n",
       "      <td>0.351648</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>79</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>60</td>\n",
       "      <td>165</td>\n",
       "      <td>55</td>\n",
       "      <td>165</td>\n",
       "      <td>0.363636</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>80</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(-inf, 480.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>81</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(480.0, 520.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>82</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(520.0, 540.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(540.0, 580.0]</td>\n",
       "      <td>86</td>\n",
       "      <td>159</td>\n",
       "      <td>81</td>\n",
       "      <td>159</td>\n",
       "      <td>0.540881</td>\n",
       "      <td>0.509434</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>84</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(580.0, inf]</td>\n",
       "      <td>48</td>\n",
       "      <td>135</td>\n",
       "      <td>43</td>\n",
       "      <td>135</td>\n",
       "      <td>0.355556</td>\n",
       "      <td>0.318519</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      repayment_week     scorev1_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n",
       "0   2023.11.27~12.03   (-inf, 480.0]        7       11        7       11   \n",
       "1   2023.11.27~12.03  (480.0, 520.0]       45       75       42       75   \n",
       "2   2023.11.27~12.03  (520.0, 540.0]       32       66       29       66   \n",
       "3   2023.11.27~12.03  (540.0, 580.0]       64      160       62      160   \n",
       "4   2023.11.27~12.03    (580.0, inf]       11       23       11       23   \n",
       "5   2023.12.04~12.10   (-inf, 480.0]       10       21       10       21   \n",
       "6   2023.12.04~12.10  (480.0, 520.0]       77      135       77      135   \n",
       "7   2023.12.04~12.10  (520.0, 540.0]       70      141       64      141   \n",
       "8   2023.12.04~12.10  (540.0, 580.0]       97      233       91      233   \n",
       "9   2023.12.04~12.10    (580.0, inf]       33       88       32       88   \n",
       "10  2023.12.11~12.17   (-inf, 480.0]       19       36       16       36   \n",
       "11  2023.12.11~12.17  (480.0, 520.0]       58      133       56      133   \n",
       "12  2023.12.11~12.17  (520.0, 540.0]       37       99       32       99   \n",
       "13  2023.12.11~12.17  (540.0, 580.0]       77      207       74      207   \n",
       "14  2023.12.11~12.17    (580.0, inf]       23       61       23       61   \n",
       "15  2023.12.18~12.24   (-inf, 480.0]       21       53       21       53   \n",
       "16  2023.12.18~12.24  (480.0, 520.0]      103      245      101      245   \n",
       "17  2023.12.18~12.24  (520.0, 540.0]       83      202       77      202   \n",
       "18  2023.12.18~12.24  (540.0, 580.0]      164      378      155      378   \n",
       "19  2023.12.18~12.24    (580.0, inf]       33       93       31       93   \n",
       "20  2023.12.25~12.31   (-inf, 480.0]       42       57       42       57   \n",
       "21  2023.12.25~12.31  (480.0, 520.0]       74      203       68      203   \n",
       "22  2023.12.25~12.31  (520.0, 540.0]       73      163       67      163   \n",
       "23  2023.12.25~12.31  (540.0, 580.0]      107      262      105      262   \n",
       "24  2023.12.25~12.31    (580.0, inf]       40       94       39       94   \n",
       "25  2024.01.01~01.07   (-inf, 480.0]       72      119       68      119   \n",
       "26  2024.01.01~01.07  (480.0, 520.0]      290      502      275      502   \n",
       "27  2024.01.01~01.07  (520.0, 540.0]      200      401      192      401   \n",
       "28  2024.01.01~01.07  (540.0, 580.0]      299      697      279      697   \n",
       "29  2024.01.01~01.07    (580.0, inf]       82      236       74      236   \n",
       "30  2024.01.08~01.14   (-inf, 480.0]       38       60       36       60   \n",
       "31  2024.01.08~01.14  (480.0, 520.0]      167      337      161      337   \n",
       "32  2024.01.08~01.14  (520.0, 540.0]      179      344      174      344   \n",
       "33  2024.01.08~01.14  (540.0, 580.0]      300      643      272      643   \n",
       "34  2024.01.08~01.14    (580.0, inf]       92      278       83      278   \n",
       "35  2024.01.15~01.21   (-inf, 480.0]       27       36       25       36   \n",
       "36  2024.01.15~01.21  (480.0, 520.0]      147      292      138      292   \n",
       "37  2024.01.15~01.21  (520.0, 540.0]      145      269      138      269   \n",
       "38  2024.01.15~01.21  (540.0, 580.0]      242      552      232      552   \n",
       "39  2024.01.15~01.21    (580.0, inf]       96      223       90      223   \n",
       "40  2024.01.22~01.28   (-inf, 480.0]       10       13       10       13   \n",
       "41  2024.01.22~01.28  (480.0, 520.0]      241      402      228      402   \n",
       "42  2024.01.22~01.28  (520.0, 540.0]      232      423      225      423   \n",
       "43  2024.01.22~01.28  (540.0, 580.0]      323      658      298      658   \n",
       "44  2024.01.22~01.28    (580.0, inf]      102      226       99      226   \n",
       "45  2024.01.29~02.04   (-inf, 480.0]        0        5        0        5   \n",
       "46  2024.01.29~02.04  (480.0, 520.0]       70      120       67      120   \n",
       "47  2024.01.29~02.04  (520.0, 540.0]       86      179       84      179   \n",
       "48  2024.01.29~02.04  (540.0, 580.0]      165      361      149      361   \n",
       "49  2024.01.29~02.04    (580.0, inf]       70      171       66      171   \n",
       "50  2024.02.05~02.11   (-inf, 480.0]        0        6        0        6   \n",
       "51  2024.02.05~02.11  (480.0, 520.0]        4       10        4       10   \n",
       "52  2024.02.05~02.11  (520.0, 540.0]        5       13        5       13   \n",
       "53  2024.02.05~02.11  (540.0, 580.0]       74      218       66      218   \n",
       "54  2024.02.05~02.11    (580.0, inf]       35      142       28      142   \n",
       "55  2024.02.12~02.18   (-inf, 480.0]        2        3        1        3   \n",
       "56  2024.02.12~02.18  (480.0, 520.0]        4        6        2        6   \n",
       "57  2024.02.12~02.18  (520.0, 540.0]        1        4        1        4   \n",
       "58  2024.02.12~02.18  (540.0, 580.0]       48      153       41      153   \n",
       "59  2024.02.12~02.18    (580.0, inf]       42      104       34      104   \n",
       "60  2024.02.19~02.25   (-inf, 480.0]        0        1        0        1   \n",
       "61  2024.02.19~02.25  (480.0, 520.0]        2        4        2        4   \n",
       "62  2024.02.19~02.25  (520.0, 540.0]        0        3        0        3   \n",
       "63  2024.02.19~02.25  (540.0, 580.0]       54      176       53      176   \n",
       "64  2024.02.19~02.25    (580.0, inf]       37      134       26      134   \n",
       "65  2024.02.26~03.03   (-inf, 480.0]        0        2        0        2   \n",
       "66  2024.02.26~03.03  (480.0, 520.0]        8       22        6       22   \n",
       "67  2024.02.26~03.03  (520.0, 540.0]       11       34       11       34   \n",
       "68  2024.02.26~03.03  (540.0, 580.0]       73      180       70      180   \n",
       "69  2024.02.26~03.03    (580.0, inf]       42      125       38      125   \n",
       "70  2024.03.04~03.10   (-inf, 480.0]        1        1        1        1   \n",
       "71  2024.03.04~03.10  (480.0, 520.0]        0        1        0        1   \n",
       "72  2024.03.04~03.10  (520.0, 540.0]        2        8        1        8   \n",
       "73  2024.03.04~03.10  (540.0, 580.0]       84      221       78      221   \n",
       "74  2024.03.04~03.10    (580.0, inf]       59      124       58      124   \n",
       "75  2024.03.11~03.17   (-inf, 480.0]        0        0        0        0   \n",
       "76  2024.03.11~03.17  (480.0, 520.0]        0        2        0        2   \n",
       "77  2024.03.11~03.17  (520.0, 540.0]        3        5        3        5   \n",
       "78  2024.03.11~03.17  (540.0, 580.0]       68      182       64      182   \n",
       "79  2024.03.11~03.17    (580.0, inf]       60      165       55      165   \n",
       "80  2024.03.18~03.24   (-inf, 480.0]        0        0        0        0   \n",
       "81  2024.03.18~03.24  (480.0, 520.0]        0        0        0        0   \n",
       "82  2024.03.18~03.24  (520.0, 540.0]        2        4        2        4   \n",
       "83  2024.03.18~03.24  (540.0, 580.0]       86      159       81      159   \n",
       "84  2024.03.18~03.24    (580.0, inf]       48      135       43      135   \n",
       "\n",
       "         pd1       cpd  \n",
       "0   0.636364  0.636364  \n",
       "1   0.600000  0.560000  \n",
       "2   0.484848  0.439394  \n",
       "3   0.400000  0.387500  \n",
       "4   0.478261  0.478261  \n",
       "5   0.476190  0.476190  \n",
       "6   0.570370  0.570370  \n",
       "7   0.496454  0.453901  \n",
       "8   0.416309  0.390558  \n",
       "9   0.375000  0.363636  \n",
       "10  0.527778  0.444444  \n",
       "11  0.436090  0.421053  \n",
       "12  0.373737  0.323232  \n",
       "13  0.371981  0.357488  \n",
       "14  0.377049  0.377049  \n",
       "15  0.396226  0.396226  \n",
       "16  0.420408  0.412245  \n",
       "17  0.410891  0.381188  \n",
       "18  0.433862  0.410053  \n",
       "19  0.354839  0.333333  \n",
       "20  0.736842  0.736842  \n",
       "21  0.364532  0.334975  \n",
       "22  0.447853  0.411043  \n",
       "23  0.408397  0.400763  \n",
       "24  0.425532  0.414894  \n",
       "25  0.605042  0.571429  \n",
       "26  0.577689  0.547809  \n",
       "27  0.498753  0.478803  \n",
       "28  0.428981  0.400287  \n",
       "29  0.347458  0.313559  \n",
       "30  0.633333  0.600000  \n",
       "31  0.495549  0.477745  \n",
       "32  0.520349  0.505814  \n",
       "33  0.466563  0.423017  \n",
       "34  0.330935  0.298561  \n",
       "35  0.750000  0.694444  \n",
       "36  0.503425  0.472603  \n",
       "37  0.539033  0.513011  \n",
       "38  0.438406  0.420290  \n",
       "39  0.430493  0.403587  \n",
       "40  0.769231  0.769231  \n",
       "41  0.599502  0.567164  \n",
       "42  0.548463  0.531915  \n",
       "43  0.490881  0.452888  \n",
       "44  0.451327  0.438053  \n",
       "45  0.000000  0.000000  \n",
       "46  0.583333  0.558333  \n",
       "47  0.480447  0.469274  \n",
       "48  0.457064  0.412742  \n",
       "49  0.409357  0.385965  \n",
       "50  0.000000  0.000000  \n",
       "51  0.400000  0.400000  \n",
       "52  0.384615  0.384615  \n",
       "53  0.339450  0.302752  \n",
       "54  0.246479  0.197183  \n",
       "55  0.666667  0.333333  \n",
       "56  0.666667  0.333333  \n",
       "57  0.250000  0.250000  \n",
       "58  0.313725  0.267974  \n",
       "59  0.403846  0.326923  \n",
       "60  0.000000  0.000000  \n",
       "61  0.500000  0.500000  \n",
       "62  0.000000  0.000000  \n",
       "63  0.306818  0.301136  \n",
       "64  0.276119  0.194030  \n",
       "65  0.000000  0.000000  \n",
       "66  0.363636  0.272727  \n",
       "67  0.323529  0.323529  \n",
       "68  0.405556  0.388889  \n",
       "69  0.336000  0.304000  \n",
       "70  1.000000  1.000000  \n",
       "71  0.000000  0.000000  \n",
       "72  0.250000  0.125000  \n",
       "73  0.380090  0.352941  \n",
       "74  0.475806  0.467742  \n",
       "75       NaN       NaN  \n",
       "76  0.000000  0.000000  \n",
       "77  0.600000  0.600000  \n",
       "78  0.373626  0.351648  \n",
       "79  0.363636  0.333333  \n",
       "80       NaN       NaN  \n",
       "81       NaN       NaN  \n",
       "82  0.500000  0.500000  \n",
       "83  0.540881  0.509434  \n",
       "84  0.355556  0.318519  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition  = (df.merchant_id=='AM') & (df.device_type ==\"android\") & (df.new_old_user_status== 2 ) & (df.scorev1>0) & (df.repayment_date>=pd.to_datetime('2023-11-27'))\n",
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev1_bin']\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5d1ee48da026905b",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "# scorev2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "7dfb5cb4acf4ad49",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:39:00.771542Z",
     "start_time": "2024-03-20T06:39:00.697694Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev2_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>10</td>\n",
       "      <td>21</td>\n",
       "      <td>31</td>\n",
       "      <td>0.002891</td>\n",
       "      <td>0.677419</td>\n",
       "      <td>-0.898049</td>\n",
       "      <td>1.781091</td>\n",
       "      <td>0.003644</td>\n",
       "      <td>0.132406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev2_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>283</td>\n",
       "      <td>367</td>\n",
       "      <td>650</td>\n",
       "      <td>0.060623</td>\n",
       "      <td>0.564615</td>\n",
       "      <td>-0.735867</td>\n",
       "      <td>1.484504</td>\n",
       "      <td>0.051045</td>\n",
       "      <td>0.132406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev2_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>1216</td>\n",
       "      <td>1087</td>\n",
       "      <td>2303</td>\n",
       "      <td>0.214792</td>\n",
       "      <td>0.471993</td>\n",
       "      <td>-0.374258</td>\n",
       "      <td>1.240978</td>\n",
       "      <td>0.134575</td>\n",
       "      <td>0.132406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev2_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>1331</td>\n",
       "      <td>947</td>\n",
       "      <td>2278</td>\n",
       "      <td>0.212460</td>\n",
       "      <td>0.415716</td>\n",
       "      <td>-0.147038</td>\n",
       "      <td>1.093012</td>\n",
       "      <td>0.166465</td>\n",
       "      <td>0.132406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>scorev2_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>2356</td>\n",
       "      <td>1068</td>\n",
       "      <td>3424</td>\n",
       "      <td>0.319343</td>\n",
       "      <td>0.311916</td>\n",
       "      <td>0.302075</td>\n",
       "      <td>0.820099</td>\n",
       "      <td>0.073753</td>\n",
       "      <td>0.132406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>scorev2_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>1448</td>\n",
       "      <td>588</td>\n",
       "      <td>2036</td>\n",
       "      <td>0.189890</td>\n",
       "      <td>0.288802</td>\n",
       "      <td>0.410771</td>\n",
       "      <td>0.759326</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.132406</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev2_bin  def_pd1   (-inf, 500.0]        10        21     31   \n",
       "1  scorev2_bin  def_pd1  (500.0, 520.0]       283       367    650   \n",
       "2  scorev2_bin  def_pd1  (520.0, 550.0]      1216      1087   2303   \n",
       "3  scorev2_bin  def_pd1  (550.0, 570.0]      1331       947   2278   \n",
       "4  scorev2_bin  def_pd1  (570.0, 605.0]      2356      1068   3424   \n",
       "5  scorev2_bin  def_pd1    (605.0, inf]      1448       588   2036   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.002891       0.677419 -0.898049  1.781091  0.003644  0.132406  \n",
       "1    0.060623       0.564615 -0.735867  1.484504  0.051045  0.132406  \n",
       "2    0.214792       0.471993 -0.374258  1.240978  0.134575  0.132406  \n",
       "3    0.212460       0.415716 -0.147038  1.093012  0.166465  0.132406  \n",
       "4    0.319343       0.311916  0.302075  0.820099  0.073753  0.132406  \n",
       "5    0.189890       0.288802  0.410771  0.759326  0.000000  0.132406  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition  = (df.merchant_id=='AC') & (df.device_type ==\"android\") & (df.new_old_user_status== 0 ) & (df.scorev2>0) & (df.repayment_date>=pd.to_datetime('2023-11-27'))\n",
    "df['scorev2_bin'] = pd.cut(df['scorev2'],[-np.inf,500,520,550,570,605,np.inf])\n",
    "kit.univerate(df[condition],'scorev2_bin','def_pd1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "abb6dc3b5a1b5b34",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:39:22.468502Z",
     "start_time": "2024-03-20T06:39:22.439666Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_367786/218088919.py:63: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.\n",
      "  grouped = data.groupby(group)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>repayment_week</th>\n",
       "      <th>scorev2_bin</th>\n",
       "      <th>def_pd1</th>\n",
       "      <th>agr_pd1</th>\n",
       "      <th>def_cpd</th>\n",
       "      <th>agr_cpd</th>\n",
       "      <th>pd1</th>\n",
       "      <th>cpd</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023.12.04~12.10</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2023.12.04~12.10</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.666667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2023.12.04~12.10</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>25</td>\n",
       "      <td>37</td>\n",
       "      <td>23</td>\n",
       "      <td>37</td>\n",
       "      <td>0.675676</td>\n",
       "      <td>0.621622</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2023.12.04~12.10</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>14</td>\n",
       "      <td>25</td>\n",
       "      <td>11</td>\n",
       "      <td>25</td>\n",
       "      <td>0.560000</td>\n",
       "      <td>0.440000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2023.12.04~12.10</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>26</td>\n",
       "      <td>58</td>\n",
       "      <td>22</td>\n",
       "      <td>58</td>\n",
       "      <td>0.448276</td>\n",
       "      <td>0.379310</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2023.12.04~12.10</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>3</td>\n",
       "      <td>25</td>\n",
       "      <td>3</td>\n",
       "      <td>25</td>\n",
       "      <td>0.120000</td>\n",
       "      <td>0.120000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2023.12.11~12.17</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "      <td>7</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.428571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2023.12.11~12.17</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>17</td>\n",
       "      <td>25</td>\n",
       "      <td>17</td>\n",
       "      <td>25</td>\n",
       "      <td>0.680000</td>\n",
       "      <td>0.680000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2023.12.11~12.17</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>41</td>\n",
       "      <td>78</td>\n",
       "      <td>34</td>\n",
       "      <td>78</td>\n",
       "      <td>0.525641</td>\n",
       "      <td>0.435897</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2023.12.11~12.17</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>64</td>\n",
       "      <td>124</td>\n",
       "      <td>51</td>\n",
       "      <td>124</td>\n",
       "      <td>0.516129</td>\n",
       "      <td>0.411290</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2023.12.11~12.17</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>77</td>\n",
       "      <td>233</td>\n",
       "      <td>63</td>\n",
       "      <td>233</td>\n",
       "      <td>0.330472</td>\n",
       "      <td>0.270386</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2023.12.11~12.17</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>54</td>\n",
       "      <td>164</td>\n",
       "      <td>41</td>\n",
       "      <td>164</td>\n",
       "      <td>0.329268</td>\n",
       "      <td>0.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2023.12.18~12.24</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2023.12.18~12.24</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>8</td>\n",
       "      <td>14</td>\n",
       "      <td>8</td>\n",
       "      <td>14</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.571429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2023.12.18~12.24</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>38</td>\n",
       "      <td>73</td>\n",
       "      <td>35</td>\n",
       "      <td>73</td>\n",
       "      <td>0.520548</td>\n",
       "      <td>0.479452</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2023.12.18~12.24</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>37</td>\n",
       "      <td>85</td>\n",
       "      <td>32</td>\n",
       "      <td>85</td>\n",
       "      <td>0.435294</td>\n",
       "      <td>0.376471</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2023.12.18~12.24</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>58</td>\n",
       "      <td>183</td>\n",
       "      <td>46</td>\n",
       "      <td>183</td>\n",
       "      <td>0.316940</td>\n",
       "      <td>0.251366</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2023.12.18~12.24</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>18</td>\n",
       "      <td>114</td>\n",
       "      <td>13</td>\n",
       "      <td>114</td>\n",
       "      <td>0.157895</td>\n",
       "      <td>0.114035</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>9</td>\n",
       "      <td>18</td>\n",
       "      <td>9</td>\n",
       "      <td>18</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>12</td>\n",
       "      <td>30</td>\n",
       "      <td>9</td>\n",
       "      <td>30</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>0.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>26</td>\n",
       "      <td>74</td>\n",
       "      <td>22</td>\n",
       "      <td>74</td>\n",
       "      <td>0.351351</td>\n",
       "      <td>0.297297</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>16</td>\n",
       "      <td>46</td>\n",
       "      <td>9</td>\n",
       "      <td>46</td>\n",
       "      <td>0.347826</td>\n",
       "      <td>0.195652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>20</td>\n",
       "      <td>36</td>\n",
       "      <td>19</td>\n",
       "      <td>36</td>\n",
       "      <td>0.555556</td>\n",
       "      <td>0.527778</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>56</td>\n",
       "      <td>94</td>\n",
       "      <td>52</td>\n",
       "      <td>94</td>\n",
       "      <td>0.595745</td>\n",
       "      <td>0.553191</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>59</td>\n",
       "      <td>123</td>\n",
       "      <td>56</td>\n",
       "      <td>123</td>\n",
       "      <td>0.479675</td>\n",
       "      <td>0.455285</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>94</td>\n",
       "      <td>272</td>\n",
       "      <td>80</td>\n",
       "      <td>272</td>\n",
       "      <td>0.345588</td>\n",
       "      <td>0.294118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>81</td>\n",
       "      <td>276</td>\n",
       "      <td>60</td>\n",
       "      <td>276</td>\n",
       "      <td>0.293478</td>\n",
       "      <td>0.217391</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>15</td>\n",
       "      <td>35</td>\n",
       "      <td>14</td>\n",
       "      <td>35</td>\n",
       "      <td>0.428571</td>\n",
       "      <td>0.400000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>63</td>\n",
       "      <td>101</td>\n",
       "      <td>58</td>\n",
       "      <td>101</td>\n",
       "      <td>0.623762</td>\n",
       "      <td>0.574257</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>160</td>\n",
       "      <td>305</td>\n",
       "      <td>148</td>\n",
       "      <td>305</td>\n",
       "      <td>0.524590</td>\n",
       "      <td>0.485246</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>150</td>\n",
       "      <td>368</td>\n",
       "      <td>136</td>\n",
       "      <td>368</td>\n",
       "      <td>0.407609</td>\n",
       "      <td>0.369565</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>113</td>\n",
       "      <td>346</td>\n",
       "      <td>95</td>\n",
       "      <td>346</td>\n",
       "      <td>0.326590</td>\n",
       "      <td>0.274566</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>60</td>\n",
       "      <td>94</td>\n",
       "      <td>58</td>\n",
       "      <td>94</td>\n",
       "      <td>0.638298</td>\n",
       "      <td>0.617021</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>97</td>\n",
       "      <td>191</td>\n",
       "      <td>93</td>\n",
       "      <td>191</td>\n",
       "      <td>0.507853</td>\n",
       "      <td>0.486911</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>66</td>\n",
       "      <td>181</td>\n",
       "      <td>58</td>\n",
       "      <td>181</td>\n",
       "      <td>0.364641</td>\n",
       "      <td>0.320442</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>94</td>\n",
       "      <td>341</td>\n",
       "      <td>86</td>\n",
       "      <td>341</td>\n",
       "      <td>0.275660</td>\n",
       "      <td>0.252199</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>66</td>\n",
       "      <td>227</td>\n",
       "      <td>48</td>\n",
       "      <td>227</td>\n",
       "      <td>0.290749</td>\n",
       "      <td>0.211454</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>18</td>\n",
       "      <td>28</td>\n",
       "      <td>16</td>\n",
       "      <td>28</td>\n",
       "      <td>0.642857</td>\n",
       "      <td>0.571429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>98</td>\n",
       "      <td>226</td>\n",
       "      <td>88</td>\n",
       "      <td>226</td>\n",
       "      <td>0.433628</td>\n",
       "      <td>0.389381</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>66</td>\n",
       "      <td>170</td>\n",
       "      <td>53</td>\n",
       "      <td>170</td>\n",
       "      <td>0.388235</td>\n",
       "      <td>0.311765</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>78</td>\n",
       "      <td>283</td>\n",
       "      <td>58</td>\n",
       "      <td>283</td>\n",
       "      <td>0.275618</td>\n",
       "      <td>0.204947</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>36</td>\n",
       "      <td>142</td>\n",
       "      <td>29</td>\n",
       "      <td>142</td>\n",
       "      <td>0.253521</td>\n",
       "      <td>0.204225</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>28</td>\n",
       "      <td>47</td>\n",
       "      <td>26</td>\n",
       "      <td>47</td>\n",
       "      <td>0.595745</td>\n",
       "      <td>0.553191</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>131</td>\n",
       "      <td>306</td>\n",
       "      <td>115</td>\n",
       "      <td>306</td>\n",
       "      <td>0.428105</td>\n",
       "      <td>0.375817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>81</td>\n",
       "      <td>240</td>\n",
       "      <td>70</td>\n",
       "      <td>240</td>\n",
       "      <td>0.337500</td>\n",
       "      <td>0.291667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>88</td>\n",
       "      <td>366</td>\n",
       "      <td>70</td>\n",
       "      <td>366</td>\n",
       "      <td>0.240437</td>\n",
       "      <td>0.191257</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>50</td>\n",
       "      <td>162</td>\n",
       "      <td>42</td>\n",
       "      <td>162</td>\n",
       "      <td>0.308642</td>\n",
       "      <td>0.259259</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>10</td>\n",
       "      <td>13</td>\n",
       "      <td>10</td>\n",
       "      <td>13</td>\n",
       "      <td>0.769231</td>\n",
       "      <td>0.769231</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>82</td>\n",
       "      <td>174</td>\n",
       "      <td>74</td>\n",
       "      <td>174</td>\n",
       "      <td>0.471264</td>\n",
       "      <td>0.425287</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>65</td>\n",
       "      <td>171</td>\n",
       "      <td>48</td>\n",
       "      <td>171</td>\n",
       "      <td>0.380117</td>\n",
       "      <td>0.280702</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>69</td>\n",
       "      <td>268</td>\n",
       "      <td>53</td>\n",
       "      <td>268</td>\n",
       "      <td>0.257463</td>\n",
       "      <td>0.197761</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>25</td>\n",
       "      <td>109</td>\n",
       "      <td>21</td>\n",
       "      <td>109</td>\n",
       "      <td>0.229358</td>\n",
       "      <td>0.192661</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>55</td>\n",
       "      <td>154</td>\n",
       "      <td>49</td>\n",
       "      <td>154</td>\n",
       "      <td>0.357143</td>\n",
       "      <td>0.318182</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>63</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>61</td>\n",
       "      <td>153</td>\n",
       "      <td>47</td>\n",
       "      <td>153</td>\n",
       "      <td>0.398693</td>\n",
       "      <td>0.307190</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>64</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>75</td>\n",
       "      <td>228</td>\n",
       "      <td>59</td>\n",
       "      <td>228</td>\n",
       "      <td>0.328947</td>\n",
       "      <td>0.258772</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>65</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>26</td>\n",
       "      <td>95</td>\n",
       "      <td>21</td>\n",
       "      <td>95</td>\n",
       "      <td>0.273684</td>\n",
       "      <td>0.221053</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>67</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>0.750000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>68</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>62</td>\n",
       "      <td>155</td>\n",
       "      <td>54</td>\n",
       "      <td>155</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>0.348387</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>69</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>65</td>\n",
       "      <td>171</td>\n",
       "      <td>49</td>\n",
       "      <td>171</td>\n",
       "      <td>0.380117</td>\n",
       "      <td>0.286550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>80</td>\n",
       "      <td>214</td>\n",
       "      <td>66</td>\n",
       "      <td>214</td>\n",
       "      <td>0.373832</td>\n",
       "      <td>0.308411</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>71</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>27</td>\n",
       "      <td>94</td>\n",
       "      <td>20</td>\n",
       "      <td>94</td>\n",
       "      <td>0.287234</td>\n",
       "      <td>0.212766</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>73</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>53</td>\n",
       "      <td>122</td>\n",
       "      <td>48</td>\n",
       "      <td>122</td>\n",
       "      <td>0.434426</td>\n",
       "      <td>0.393443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>53</td>\n",
       "      <td>147</td>\n",
       "      <td>42</td>\n",
       "      <td>147</td>\n",
       "      <td>0.360544</td>\n",
       "      <td>0.285714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>76</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>62</td>\n",
       "      <td>209</td>\n",
       "      <td>52</td>\n",
       "      <td>209</td>\n",
       "      <td>0.296651</td>\n",
       "      <td>0.248804</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>77</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>29</td>\n",
       "      <td>100</td>\n",
       "      <td>21</td>\n",
       "      <td>100</td>\n",
       "      <td>0.290000</td>\n",
       "      <td>0.210000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>79</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>18</td>\n",
       "      <td>49</td>\n",
       "      <td>17</td>\n",
       "      <td>49</td>\n",
       "      <td>0.367347</td>\n",
       "      <td>0.346939</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>80</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>46</td>\n",
       "      <td>127</td>\n",
       "      <td>44</td>\n",
       "      <td>127</td>\n",
       "      <td>0.362205</td>\n",
       "      <td>0.346457</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>81</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>40</td>\n",
       "      <td>127</td>\n",
       "      <td>37</td>\n",
       "      <td>127</td>\n",
       "      <td>0.314961</td>\n",
       "      <td>0.291339</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>82</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>30</td>\n",
       "      <td>126</td>\n",
       "      <td>26</td>\n",
       "      <td>126</td>\n",
       "      <td>0.238095</td>\n",
       "      <td>0.206349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>18</td>\n",
       "      <td>65</td>\n",
       "      <td>15</td>\n",
       "      <td>65</td>\n",
       "      <td>0.276923</td>\n",
       "      <td>0.230769</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>84</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>6</td>\n",
       "      <td>10</td>\n",
       "      <td>6</td>\n",
       "      <td>10</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>85</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>98</td>\n",
       "      <td>168</td>\n",
       "      <td>94</td>\n",
       "      <td>168</td>\n",
       "      <td>0.583333</td>\n",
       "      <td>0.559524</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>132</td>\n",
       "      <td>250</td>\n",
       "      <td>122</td>\n",
       "      <td>250</td>\n",
       "      <td>0.528000</td>\n",
       "      <td>0.488000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>58</td>\n",
       "      <td>131</td>\n",
       "      <td>46</td>\n",
       "      <td>131</td>\n",
       "      <td>0.442748</td>\n",
       "      <td>0.351145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>37</td>\n",
       "      <td>126</td>\n",
       "      <td>31</td>\n",
       "      <td>126</td>\n",
       "      <td>0.293651</td>\n",
       "      <td>0.246032</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>12</td>\n",
       "      <td>43</td>\n",
       "      <td>11</td>\n",
       "      <td>43</td>\n",
       "      <td>0.279070</td>\n",
       "      <td>0.255814</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(-inf, 500.0]</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>0.750000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(500.0, 520.0]</td>\n",
       "      <td>61</td>\n",
       "      <td>115</td>\n",
       "      <td>59</td>\n",
       "      <td>115</td>\n",
       "      <td>0.530435</td>\n",
       "      <td>0.513043</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(520.0, 550.0]</td>\n",
       "      <td>99</td>\n",
       "      <td>197</td>\n",
       "      <td>91</td>\n",
       "      <td>197</td>\n",
       "      <td>0.502538</td>\n",
       "      <td>0.461929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>93</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(550.0, 570.0]</td>\n",
       "      <td>46</td>\n",
       "      <td>95</td>\n",
       "      <td>43</td>\n",
       "      <td>95</td>\n",
       "      <td>0.484211</td>\n",
       "      <td>0.452632</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>94</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(570.0, 605.0]</td>\n",
       "      <td>24</td>\n",
       "      <td>75</td>\n",
       "      <td>23</td>\n",
       "      <td>75</td>\n",
       "      <td>0.320000</td>\n",
       "      <td>0.306667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>95</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(605.0, inf]</td>\n",
       "      <td>14</td>\n",
       "      <td>28</td>\n",
       "      <td>11</td>\n",
       "      <td>28</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.392857</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      repayment_week     scorev2_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n",
       "0   2023.12.04~12.10   (-inf, 500.0]        3        3        3        3   \n",
       "1   2023.12.04~12.10  (500.0, 520.0]        4        6        4        6   \n",
       "2   2023.12.04~12.10  (520.0, 550.0]       25       37       23       37   \n",
       "3   2023.12.04~12.10  (550.0, 570.0]       14       25       11       25   \n",
       "4   2023.12.04~12.10  (570.0, 605.0]       26       58       22       58   \n",
       "5   2023.12.04~12.10    (605.0, inf]        3       25        3       25   \n",
       "6   2023.12.11~12.17   (-inf, 500.0]        4        7        3        7   \n",
       "7   2023.12.11~12.17  (500.0, 520.0]       17       25       17       25   \n",
       "8   2023.12.11~12.17  (520.0, 550.0]       41       78       34       78   \n",
       "9   2023.12.11~12.17  (550.0, 570.0]       64      124       51      124   \n",
       "10  2023.12.11~12.17  (570.0, 605.0]       77      233       63      233   \n",
       "11  2023.12.11~12.17    (605.0, inf]       54      164       41      164   \n",
       "12  2023.12.18~12.24   (-inf, 500.0]        2        2        2        2   \n",
       "13  2023.12.18~12.24  (500.0, 520.0]        8       14        8       14   \n",
       "14  2023.12.18~12.24  (520.0, 550.0]       38       73       35       73   \n",
       "15  2023.12.18~12.24  (550.0, 570.0]       37       85       32       85   \n",
       "16  2023.12.18~12.24  (570.0, 605.0]       58      183       46      183   \n",
       "17  2023.12.18~12.24    (605.0, inf]       18      114       13      114   \n",
       "18  2023.12.25~12.31   (-inf, 500.0]        1        1        0        1   \n",
       "19  2023.12.25~12.31  (500.0, 520.0]        1        3        1        3   \n",
       "20  2023.12.25~12.31  (520.0, 550.0]        9       18        9       18   \n",
       "21  2023.12.25~12.31  (550.0, 570.0]       12       30        9       30   \n",
       "22  2023.12.25~12.31  (570.0, 605.0]       26       74       22       74   \n",
       "23  2023.12.25~12.31    (605.0, inf]       16       46        9       46   \n",
       "24  2024.01.01~01.07   (-inf, 500.0]        0        1        0        1   \n",
       "25  2024.01.01~01.07  (500.0, 520.0]       20       36       19       36   \n",
       "26  2024.01.01~01.07  (520.0, 550.0]       56       94       52       94   \n",
       "27  2024.01.01~01.07  (550.0, 570.0]       59      123       56      123   \n",
       "28  2024.01.01~01.07  (570.0, 605.0]       94      272       80      272   \n",
       "29  2024.01.01~01.07    (605.0, inf]       81      276       60      276   \n",
       "30  2024.01.08~01.14   (-inf, 500.0]        1        1        1        1   \n",
       "31  2024.01.08~01.14  (500.0, 520.0]       15       35       14       35   \n",
       "32  2024.01.08~01.14  (520.0, 550.0]       63      101       58      101   \n",
       "33  2024.01.08~01.14  (550.0, 570.0]      160      305      148      305   \n",
       "34  2024.01.08~01.14  (570.0, 605.0]      150      368      136      368   \n",
       "35  2024.01.08~01.14    (605.0, inf]      113      346       95      346   \n",
       "36  2024.01.15~01.21   (-inf, 500.0]        0        0        0        0   \n",
       "37  2024.01.15~01.21  (500.0, 520.0]       60       94       58       94   \n",
       "38  2024.01.15~01.21  (520.0, 550.0]       97      191       93      191   \n",
       "39  2024.01.15~01.21  (550.0, 570.0]       66      181       58      181   \n",
       "40  2024.01.15~01.21  (570.0, 605.0]       94      341       86      341   \n",
       "41  2024.01.15~01.21    (605.0, inf]       66      227       48      227   \n",
       "42  2024.01.22~01.28   (-inf, 500.0]        0        0        0        0   \n",
       "43  2024.01.22~01.28  (500.0, 520.0]       18       28       16       28   \n",
       "44  2024.01.22~01.28  (520.0, 550.0]       98      226       88      226   \n",
       "45  2024.01.22~01.28  (550.0, 570.0]       66      170       53      170   \n",
       "46  2024.01.22~01.28  (570.0, 605.0]       78      283       58      283   \n",
       "47  2024.01.22~01.28    (605.0, inf]       36      142       29      142   \n",
       "48  2024.01.29~02.04   (-inf, 500.0]        0        0        0        0   \n",
       "49  2024.01.29~02.04  (500.0, 520.0]       28       47       26       47   \n",
       "50  2024.01.29~02.04  (520.0, 550.0]      131      306      115      306   \n",
       "51  2024.01.29~02.04  (550.0, 570.0]       81      240       70      240   \n",
       "52  2024.01.29~02.04  (570.0, 605.0]       88      366       70      366   \n",
       "53  2024.01.29~02.04    (605.0, inf]       50      162       42      162   \n",
       "54  2024.02.05~02.11   (-inf, 500.0]        0        0        0        0   \n",
       "55  2024.02.05~02.11  (500.0, 520.0]       10       13       10       13   \n",
       "56  2024.02.05~02.11  (520.0, 550.0]       82      174       74      174   \n",
       "57  2024.02.05~02.11  (550.0, 570.0]       65      171       48      171   \n",
       "58  2024.02.05~02.11  (570.0, 605.0]       69      268       53      268   \n",
       "59  2024.02.05~02.11    (605.0, inf]       25      109       21      109   \n",
       "60  2024.02.12~02.18   (-inf, 500.0]        0        0        0        0   \n",
       "61  2024.02.12~02.18  (500.0, 520.0]        2        6        2        6   \n",
       "62  2024.02.12~02.18  (520.0, 550.0]       55      154       49      154   \n",
       "63  2024.02.12~02.18  (550.0, 570.0]       61      153       47      153   \n",
       "64  2024.02.12~02.18  (570.0, 605.0]       75      228       59      228   \n",
       "65  2024.02.12~02.18    (605.0, inf]       26       95       21       95   \n",
       "66  2024.02.19~02.25   (-inf, 500.0]        0        0        0        0   \n",
       "67  2024.02.19~02.25  (500.0, 520.0]        6        8        6        8   \n",
       "68  2024.02.19~02.25  (520.0, 550.0]       62      155       54      155   \n",
       "69  2024.02.19~02.25  (550.0, 570.0]       65      171       49      171   \n",
       "70  2024.02.19~02.25  (570.0, 605.0]       80      214       66      214   \n",
       "71  2024.02.19~02.25    (605.0, inf]       27       94       20       94   \n",
       "72  2024.02.26~03.03   (-inf, 500.0]        0        0        0        0   \n",
       "73  2024.02.26~03.03  (500.0, 520.0]        1        3        1        3   \n",
       "74  2024.02.26~03.03  (520.0, 550.0]       53      122       48      122   \n",
       "75  2024.02.26~03.03  (550.0, 570.0]       53      147       42      147   \n",
       "76  2024.02.26~03.03  (570.0, 605.0]       62      209       52      209   \n",
       "77  2024.02.26~03.03    (605.0, inf]       29      100       21      100   \n",
       "78  2024.03.04~03.10   (-inf, 500.0]        1        2        1        2   \n",
       "79  2024.03.04~03.10  (500.0, 520.0]       18       49       17       49   \n",
       "80  2024.03.04~03.10  (520.0, 550.0]       46      127       44      127   \n",
       "81  2024.03.04~03.10  (550.0, 570.0]       40      127       37      127   \n",
       "82  2024.03.04~03.10  (570.0, 605.0]       30      126       26      126   \n",
       "83  2024.03.04~03.10    (605.0, inf]       18       65       15       65   \n",
       "84  2024.03.11~03.17   (-inf, 500.0]        6       10        6       10   \n",
       "85  2024.03.11~03.17  (500.0, 520.0]       98      168       94      168   \n",
       "86  2024.03.11~03.17  (520.0, 550.0]      132      250      122      250   \n",
       "87  2024.03.11~03.17  (550.0, 570.0]       58      131       46      131   \n",
       "88  2024.03.11~03.17  (570.0, 605.0]       37      126       31      126   \n",
       "89  2024.03.11~03.17    (605.0, inf]       12       43       11       43   \n",
       "90  2024.03.18~03.24   (-inf, 500.0]        3        4        3        4   \n",
       "91  2024.03.18~03.24  (500.0, 520.0]       61      115       59      115   \n",
       "92  2024.03.18~03.24  (520.0, 550.0]       99      197       91      197   \n",
       "93  2024.03.18~03.24  (550.0, 570.0]       46       95       43       95   \n",
       "94  2024.03.18~03.24  (570.0, 605.0]       24       75       23       75   \n",
       "95  2024.03.18~03.24    (605.0, inf]       14       28       11       28   \n",
       "\n",
       "         pd1       cpd  \n",
       "0   1.000000  1.000000  \n",
       "1   0.666667  0.666667  \n",
       "2   0.675676  0.621622  \n",
       "3   0.560000  0.440000  \n",
       "4   0.448276  0.379310  \n",
       "5   0.120000  0.120000  \n",
       "6   0.571429  0.428571  \n",
       "7   0.680000  0.680000  \n",
       "8   0.525641  0.435897  \n",
       "9   0.516129  0.411290  \n",
       "10  0.330472  0.270386  \n",
       "11  0.329268  0.250000  \n",
       "12  1.000000  1.000000  \n",
       "13  0.571429  0.571429  \n",
       "14  0.520548  0.479452  \n",
       "15  0.435294  0.376471  \n",
       "16  0.316940  0.251366  \n",
       "17  0.157895  0.114035  \n",
       "18  1.000000  0.000000  \n",
       "19  0.333333  0.333333  \n",
       "20  0.500000  0.500000  \n",
       "21  0.400000  0.300000  \n",
       "22  0.351351  0.297297  \n",
       "23  0.347826  0.195652  \n",
       "24  0.000000  0.000000  \n",
       "25  0.555556  0.527778  \n",
       "26  0.595745  0.553191  \n",
       "27  0.479675  0.455285  \n",
       "28  0.345588  0.294118  \n",
       "29  0.293478  0.217391  \n",
       "30  1.000000  1.000000  \n",
       "31  0.428571  0.400000  \n",
       "32  0.623762  0.574257  \n",
       "33  0.524590  0.485246  \n",
       "34  0.407609  0.369565  \n",
       "35  0.326590  0.274566  \n",
       "36       NaN       NaN  \n",
       "37  0.638298  0.617021  \n",
       "38  0.507853  0.486911  \n",
       "39  0.364641  0.320442  \n",
       "40  0.275660  0.252199  \n",
       "41  0.290749  0.211454  \n",
       "42       NaN       NaN  \n",
       "43  0.642857  0.571429  \n",
       "44  0.433628  0.389381  \n",
       "45  0.388235  0.311765  \n",
       "46  0.275618  0.204947  \n",
       "47  0.253521  0.204225  \n",
       "48       NaN       NaN  \n",
       "49  0.595745  0.553191  \n",
       "50  0.428105  0.375817  \n",
       "51  0.337500  0.291667  \n",
       "52  0.240437  0.191257  \n",
       "53  0.308642  0.259259  \n",
       "54       NaN       NaN  \n",
       "55  0.769231  0.769231  \n",
       "56  0.471264  0.425287  \n",
       "57  0.380117  0.280702  \n",
       "58  0.257463  0.197761  \n",
       "59  0.229358  0.192661  \n",
       "60       NaN       NaN  \n",
       "61  0.333333  0.333333  \n",
       "62  0.357143  0.318182  \n",
       "63  0.398693  0.307190  \n",
       "64  0.328947  0.258772  \n",
       "65  0.273684  0.221053  \n",
       "66       NaN       NaN  \n",
       "67  0.750000  0.750000  \n",
       "68  0.400000  0.348387  \n",
       "69  0.380117  0.286550  \n",
       "70  0.373832  0.308411  \n",
       "71  0.287234  0.212766  \n",
       "72       NaN       NaN  \n",
       "73  0.333333  0.333333  \n",
       "74  0.434426  0.393443  \n",
       "75  0.360544  0.285714  \n",
       "76  0.296651  0.248804  \n",
       "77  0.290000  0.210000  \n",
       "78  0.500000  0.500000  \n",
       "79  0.367347  0.346939  \n",
       "80  0.362205  0.346457  \n",
       "81  0.314961  0.291339  \n",
       "82  0.238095  0.206349  \n",
       "83  0.276923  0.230769  \n",
       "84  0.600000  0.600000  \n",
       "85  0.583333  0.559524  \n",
       "86  0.528000  0.488000  \n",
       "87  0.442748  0.351145  \n",
       "88  0.293651  0.246032  \n",
       "89  0.279070  0.255814  \n",
       "90  0.750000  0.750000  \n",
       "91  0.530435  0.513043  \n",
       "92  0.502538  0.461929  \n",
       "93  0.484211  0.452632  \n",
       "94  0.320000  0.306667  \n",
       "95  0.500000  0.392857  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev2_bin']\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f89325cdc7cfa68",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "# scorev3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "0b1d5178",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:40:01.496613Z",
     "start_time": "2024-03-20T06:40:01.351627Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>802</td>\n",
       "      <td>675</td>\n",
       "      <td>1477</td>\n",
       "      <td>0.044034</td>\n",
       "      <td>0.457007</td>\n",
       "      <td>-0.561120</td>\n",
       "      <td>1.420267</td>\n",
       "      <td>0.027286</td>\n",
       "      <td>0.028317</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>8864</td>\n",
       "      <td>4545</td>\n",
       "      <td>13409</td>\n",
       "      <td>0.399767</td>\n",
       "      <td>0.338951</td>\n",
       "      <td>-0.077462</td>\n",
       "      <td>1.053378</td>\n",
       "      <td>0.058749</td>\n",
       "      <td>0.028317</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>6161</td>\n",
       "      <td>2871</td>\n",
       "      <td>9032</td>\n",
       "      <td>0.269274</td>\n",
       "      <td>0.317870</td>\n",
       "      <td>0.017889</td>\n",
       "      <td>0.987861</td>\n",
       "      <td>0.053930</td>\n",
       "      <td>0.028317</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>6922</td>\n",
       "      <td>2702</td>\n",
       "      <td>9624</td>\n",
       "      <td>0.286924</td>\n",
       "      <td>0.280756</td>\n",
       "      <td>0.194384</td>\n",
       "      <td>0.872522</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.028317</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev3_bin  def_pd1   (-inf, 576.0]       802       675   1477   \n",
       "1  scorev3_bin  def_pd1  (576.0, 610.0]      8864      4545  13409   \n",
       "2  scorev3_bin  def_pd1  (610.0, 620.0]      6161      2871   9032   \n",
       "3  scorev3_bin  def_pd1    (620.0, inf]      6922      2702   9624   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.044034       0.457007 -0.561120  1.420267  0.027286  0.028317  \n",
       "1    0.399767       0.338951 -0.077462  1.053378  0.058749  0.028317  \n",
       "2    0.269274       0.317870  0.017889  0.987861  0.053930  0.028317  \n",
       "3    0.286924       0.280756  0.194384  0.872522  0.000000  0.028317  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']>=1) & (df['scorev3']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-01-09\"))\n",
    "df['scorev3_bin'] = pd.cut(df['scorev3'],[-np.inf,576,610,620,np.inf])\n",
    "kit.univerate(df[condition],'scorev3_bin','def_pd1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "40ded3bc",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:40:18.331812Z",
     "start_time": "2024-03-20T06:40:18.258490Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>595</td>\n",
       "      <td>464</td>\n",
       "      <td>1059</td>\n",
       "      <td>0.061767</td>\n",
       "      <td>0.438149</td>\n",
       "      <td>-0.451687</td>\n",
       "      <td>1.326986</td>\n",
       "      <td>0.030153</td>\n",
       "      <td>0.026258</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>4727</td>\n",
       "      <td>2447</td>\n",
       "      <td>7174</td>\n",
       "      <td>0.418431</td>\n",
       "      <td>0.341093</td>\n",
       "      <td>-0.048811</td>\n",
       "      <td>1.033040</td>\n",
       "      <td>0.050793</td>\n",
       "      <td>0.026258</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>2691</td>\n",
       "      <td>1357</td>\n",
       "      <td>4048</td>\n",
       "      <td>0.236104</td>\n",
       "      <td>0.335227</td>\n",
       "      <td>-0.022622</td>\n",
       "      <td>1.015275</td>\n",
       "      <td>0.056177</td>\n",
       "      <td>0.026258</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>3471</td>\n",
       "      <td>1393</td>\n",
       "      <td>4864</td>\n",
       "      <td>0.283698</td>\n",
       "      <td>0.286390</td>\n",
       "      <td>0.204876</td>\n",
       "      <td>0.867365</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.026258</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev3_bin  def_pd1   (-inf, 576.0]       595       464   1059   \n",
       "1  scorev3_bin  def_pd1  (576.0, 610.0]      4727      2447   7174   \n",
       "2  scorev3_bin  def_pd1  (610.0, 620.0]      2691      1357   4048   \n",
       "3  scorev3_bin  def_pd1    (620.0, inf]      3471      1393   4864   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.061767       0.438149 -0.451687  1.326986  0.030153  0.026258  \n",
       "1    0.418431       0.341093 -0.048811  1.033040  0.050793  0.026258  \n",
       "2    0.236104       0.335227 -0.022622  1.015275  0.056177  0.026258  \n",
       "3    0.283698       0.286390  0.204876  0.867365  0.000000  0.026258  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']==1) & (df['scorev3']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-01-09\"))\n",
    "df['scorev3_bin'] = pd.cut(df['scorev3'],[-np.inf,576,610,620,np.inf])\n",
    "kit.univerate(df[condition],'scorev3_bin','def_pd1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "a88f520f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:40:36.542049Z",
     "start_time": "2024-03-20T06:40:36.218725Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>207</td>\n",
       "      <td>211</td>\n",
       "      <td>418</td>\n",
       "      <td>0.025492</td>\n",
       "      <td>0.504785</td>\n",
       "      <td>-0.776385</td>\n",
       "      <td>1.612813</td>\n",
       "      <td>0.022739</td>\n",
       "      <td>0.032021</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>4137</td>\n",
       "      <td>2098</td>\n",
       "      <td>6235</td>\n",
       "      <td>0.380252</td>\n",
       "      <td>0.336488</td>\n",
       "      <td>-0.106943</td>\n",
       "      <td>1.075095</td>\n",
       "      <td>0.064303</td>\n",
       "      <td>0.032021</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>3470</td>\n",
       "      <td>1514</td>\n",
       "      <td>4984</td>\n",
       "      <td>0.303958</td>\n",
       "      <td>0.303772</td>\n",
       "      <td>0.043051</td>\n",
       "      <td>0.970567</td>\n",
       "      <td>0.051281</td>\n",
       "      <td>0.032021</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev3_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>3451</td>\n",
       "      <td>1309</td>\n",
       "      <td>4760</td>\n",
       "      <td>0.290297</td>\n",
       "      <td>0.275000</td>\n",
       "      <td>0.182542</td>\n",
       "      <td>0.878639</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.032021</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev3_bin  def_pd1   (-inf, 576.0]       207       211    418   \n",
       "1  scorev3_bin  def_pd1  (576.0, 610.0]      4137      2098   6235   \n",
       "2  scorev3_bin  def_pd1  (610.0, 620.0]      3470      1514   4984   \n",
       "3  scorev3_bin  def_pd1    (620.0, inf]      3451      1309   4760   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.025492       0.504785 -0.776385  1.612813  0.022739  0.032021  \n",
       "1    0.380252       0.336488 -0.106943  1.075095  0.064303  0.032021  \n",
       "2    0.303958       0.303772  0.043051  0.970567  0.051281  0.032021  \n",
       "3    0.290297       0.275000  0.182542  0.878639  0.000000  0.032021  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']==2) & (df['scorev3']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-01-09\"))\n",
    "df['scorev3_bin'] = pd.cut(df['scorev3'],[-np.inf,576,610,620,np.inf])\n",
    "kit.univerate(df[condition],'scorev3_bin','def_pd1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "895cb896",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:40:57.650220Z",
     "start_time": "2024-03-20T06:40:57.584854Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_27965/1208034288.py:63: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.\n",
      "  grouped = data.groupby(group)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>repayment_week</th>\n",
       "      <th>scorev3_bin</th>\n",
       "      <th>def_pd1</th>\n",
       "      <th>agr_pd1</th>\n",
       "      <th>def_cpd</th>\n",
       "      <th>agr_cpd</th>\n",
       "      <th>pd1</th>\n",
       "      <th>cpd</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>88</td>\n",
       "      <td>187</td>\n",
       "      <td>67</td>\n",
       "      <td>187</td>\n",
       "      <td>0.470588</td>\n",
       "      <td>0.358289</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>539</td>\n",
       "      <td>1286</td>\n",
       "      <td>467</td>\n",
       "      <td>1286</td>\n",
       "      <td>0.419129</td>\n",
       "      <td>0.363142</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>457</td>\n",
       "      <td>1301</td>\n",
       "      <td>401</td>\n",
       "      <td>1301</td>\n",
       "      <td>0.351268</td>\n",
       "      <td>0.308224</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>290</td>\n",
       "      <td>1054</td>\n",
       "      <td>188</td>\n",
       "      <td>1054</td>\n",
       "      <td>0.275142</td>\n",
       "      <td>0.178368</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>152</td>\n",
       "      <td>304</td>\n",
       "      <td>140</td>\n",
       "      <td>304</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.460526</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>541</td>\n",
       "      <td>1277</td>\n",
       "      <td>453</td>\n",
       "      <td>1277</td>\n",
       "      <td>0.423649</td>\n",
       "      <td>0.354738</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>300</td>\n",
       "      <td>1051</td>\n",
       "      <td>263</td>\n",
       "      <td>1051</td>\n",
       "      <td>0.285442</td>\n",
       "      <td>0.250238</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>321</td>\n",
       "      <td>1333</td>\n",
       "      <td>236</td>\n",
       "      <td>1333</td>\n",
       "      <td>0.240810</td>\n",
       "      <td>0.177044</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>269</td>\n",
       "      <td>537</td>\n",
       "      <td>233</td>\n",
       "      <td>537</td>\n",
       "      <td>0.500931</td>\n",
       "      <td>0.433892</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>546</td>\n",
       "      <td>1348</td>\n",
       "      <td>478</td>\n",
       "      <td>1348</td>\n",
       "      <td>0.405045</td>\n",
       "      <td>0.354599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>296</td>\n",
       "      <td>968</td>\n",
       "      <td>248</td>\n",
       "      <td>968</td>\n",
       "      <td>0.305785</td>\n",
       "      <td>0.256198</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>262</td>\n",
       "      <td>1105</td>\n",
       "      <td>197</td>\n",
       "      <td>1105</td>\n",
       "      <td>0.237104</td>\n",
       "      <td>0.178281</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>38</td>\n",
       "      <td>103</td>\n",
       "      <td>31</td>\n",
       "      <td>103</td>\n",
       "      <td>0.368932</td>\n",
       "      <td>0.300971</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>406</td>\n",
       "      <td>1176</td>\n",
       "      <td>335</td>\n",
       "      <td>1176</td>\n",
       "      <td>0.345238</td>\n",
       "      <td>0.284864</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>264</td>\n",
       "      <td>1052</td>\n",
       "      <td>241</td>\n",
       "      <td>1052</td>\n",
       "      <td>0.250951</td>\n",
       "      <td>0.229087</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>305</td>\n",
       "      <td>1265</td>\n",
       "      <td>270</td>\n",
       "      <td>1265</td>\n",
       "      <td>0.241107</td>\n",
       "      <td>0.213439</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>31</td>\n",
       "      <td>63</td>\n",
       "      <td>20</td>\n",
       "      <td>63</td>\n",
       "      <td>0.492063</td>\n",
       "      <td>0.317460</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>517</td>\n",
       "      <td>1341</td>\n",
       "      <td>381</td>\n",
       "      <td>1341</td>\n",
       "      <td>0.385533</td>\n",
       "      <td>0.284116</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>348</td>\n",
       "      <td>1167</td>\n",
       "      <td>299</td>\n",
       "      <td>1167</td>\n",
       "      <td>0.298201</td>\n",
       "      <td>0.256213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>481</td>\n",
       "      <td>1398</td>\n",
       "      <td>409</td>\n",
       "      <td>1398</td>\n",
       "      <td>0.344063</td>\n",
       "      <td>0.292561</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>36</td>\n",
       "      <td>78</td>\n",
       "      <td>35</td>\n",
       "      <td>78</td>\n",
       "      <td>0.461538</td>\n",
       "      <td>0.448718</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>452</td>\n",
       "      <td>1566</td>\n",
       "      <td>335</td>\n",
       "      <td>1566</td>\n",
       "      <td>0.288633</td>\n",
       "      <td>0.213921</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>338</td>\n",
       "      <td>914</td>\n",
       "      <td>298</td>\n",
       "      <td>914</td>\n",
       "      <td>0.369803</td>\n",
       "      <td>0.326039</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>232</td>\n",
       "      <td>673</td>\n",
       "      <td>197</td>\n",
       "      <td>673</td>\n",
       "      <td>0.344725</td>\n",
       "      <td>0.292719</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>24</td>\n",
       "      <td>72</td>\n",
       "      <td>13</td>\n",
       "      <td>72</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.180556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>506</td>\n",
       "      <td>1847</td>\n",
       "      <td>358</td>\n",
       "      <td>1847</td>\n",
       "      <td>0.273958</td>\n",
       "      <td>0.193828</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>212</td>\n",
       "      <td>650</td>\n",
       "      <td>183</td>\n",
       "      <td>650</td>\n",
       "      <td>0.326154</td>\n",
       "      <td>0.281538</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>207</td>\n",
       "      <td>682</td>\n",
       "      <td>159</td>\n",
       "      <td>682</td>\n",
       "      <td>0.303519</td>\n",
       "      <td>0.233138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>16</td>\n",
       "      <td>57</td>\n",
       "      <td>12</td>\n",
       "      <td>57</td>\n",
       "      <td>0.280702</td>\n",
       "      <td>0.210526</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>282</td>\n",
       "      <td>1198</td>\n",
       "      <td>223</td>\n",
       "      <td>1198</td>\n",
       "      <td>0.235392</td>\n",
       "      <td>0.186144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>195</td>\n",
       "      <td>590</td>\n",
       "      <td>169</td>\n",
       "      <td>590</td>\n",
       "      <td>0.330508</td>\n",
       "      <td>0.286441</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>197</td>\n",
       "      <td>662</td>\n",
       "      <td>161</td>\n",
       "      <td>662</td>\n",
       "      <td>0.297583</td>\n",
       "      <td>0.243202</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>11</td>\n",
       "      <td>44</td>\n",
       "      <td>10</td>\n",
       "      <td>44</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>0.227273</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>508</td>\n",
       "      <td>1559</td>\n",
       "      <td>433</td>\n",
       "      <td>1559</td>\n",
       "      <td>0.325850</td>\n",
       "      <td>0.277742</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>252</td>\n",
       "      <td>755</td>\n",
       "      <td>232</td>\n",
       "      <td>755</td>\n",
       "      <td>0.333775</td>\n",
       "      <td>0.307285</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>247</td>\n",
       "      <td>880</td>\n",
       "      <td>213</td>\n",
       "      <td>880</td>\n",
       "      <td>0.280682</td>\n",
       "      <td>0.242045</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(-inf, 576.0]</td>\n",
       "      <td>6</td>\n",
       "      <td>19</td>\n",
       "      <td>6</td>\n",
       "      <td>19</td>\n",
       "      <td>0.315789</td>\n",
       "      <td>0.315789</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(576.0, 610.0]</td>\n",
       "      <td>82</td>\n",
       "      <td>252</td>\n",
       "      <td>79</td>\n",
       "      <td>252</td>\n",
       "      <td>0.325397</td>\n",
       "      <td>0.313492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(610.0, 620.0]</td>\n",
       "      <td>74</td>\n",
       "      <td>184</td>\n",
       "      <td>73</td>\n",
       "      <td>184</td>\n",
       "      <td>0.402174</td>\n",
       "      <td>0.396739</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(620.0, inf]</td>\n",
       "      <td>52</td>\n",
       "      <td>165</td>\n",
       "      <td>49</td>\n",
       "      <td>165</td>\n",
       "      <td>0.315152</td>\n",
       "      <td>0.296970</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      repayment_week     scorev3_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n",
       "0   2024.01.08~01.14   (-inf, 576.0]        0        1        0        1   \n",
       "1   2024.01.08~01.14  (576.0, 610.0]        2        2        2        2   \n",
       "2   2024.01.08~01.14  (610.0, 620.0]        0        6        0        6   \n",
       "3   2024.01.08~01.14    (620.0, inf]        0        0        0        0   \n",
       "4   2024.01.15~01.21   (-inf, 576.0]       88      187       67      187   \n",
       "5   2024.01.15~01.21  (576.0, 610.0]      539     1286      467     1286   \n",
       "6   2024.01.15~01.21  (610.0, 620.0]      457     1301      401     1301   \n",
       "7   2024.01.15~01.21    (620.0, inf]      290     1054      188     1054   \n",
       "8   2024.01.22~01.28   (-inf, 576.0]      152      304      140      304   \n",
       "9   2024.01.22~01.28  (576.0, 610.0]      541     1277      453     1277   \n",
       "10  2024.01.22~01.28  (610.0, 620.0]      300     1051      263     1051   \n",
       "11  2024.01.22~01.28    (620.0, inf]      321     1333      236     1333   \n",
       "12  2024.01.29~02.04   (-inf, 576.0]      269      537      233      537   \n",
       "13  2024.01.29~02.04  (576.0, 610.0]      546     1348      478     1348   \n",
       "14  2024.01.29~02.04  (610.0, 620.0]      296      968      248      968   \n",
       "15  2024.01.29~02.04    (620.0, inf]      262     1105      197     1105   \n",
       "16  2024.02.05~02.11   (-inf, 576.0]       38      103       31      103   \n",
       "17  2024.02.05~02.11  (576.0, 610.0]      406     1176      335     1176   \n",
       "18  2024.02.05~02.11  (610.0, 620.0]      264     1052      241     1052   \n",
       "19  2024.02.05~02.11    (620.0, inf]      305     1265      270     1265   \n",
       "20  2024.02.12~02.18   (-inf, 576.0]       31       63       20       63   \n",
       "21  2024.02.12~02.18  (576.0, 610.0]      517     1341      381     1341   \n",
       "22  2024.02.12~02.18  (610.0, 620.0]      348     1167      299     1167   \n",
       "23  2024.02.12~02.18    (620.0, inf]      481     1398      409     1398   \n",
       "24  2024.02.19~02.25   (-inf, 576.0]       36       78       35       78   \n",
       "25  2024.02.19~02.25  (576.0, 610.0]      452     1566      335     1566   \n",
       "26  2024.02.19~02.25  (610.0, 620.0]      338      914      298      914   \n",
       "27  2024.02.19~02.25    (620.0, inf]      232      673      197      673   \n",
       "28  2024.02.26~03.03   (-inf, 576.0]       24       72       13       72   \n",
       "29  2024.02.26~03.03  (576.0, 610.0]      506     1847      358     1847   \n",
       "30  2024.02.26~03.03  (610.0, 620.0]      212      650      183      650   \n",
       "31  2024.02.26~03.03    (620.0, inf]      207      682      159      682   \n",
       "32  2024.03.04~03.10   (-inf, 576.0]       16       57       12       57   \n",
       "33  2024.03.04~03.10  (576.0, 610.0]      282     1198      223     1198   \n",
       "34  2024.03.04~03.10  (610.0, 620.0]      195      590      169      590   \n",
       "35  2024.03.04~03.10    (620.0, inf]      197      662      161      662   \n",
       "36  2024.03.11~03.17   (-inf, 576.0]       11       44       10       44   \n",
       "37  2024.03.11~03.17  (576.0, 610.0]      508     1559      433     1559   \n",
       "38  2024.03.11~03.17  (610.0, 620.0]      252      755      232      755   \n",
       "39  2024.03.11~03.17    (620.0, inf]      247      880      213      880   \n",
       "40  2024.03.18~03.24   (-inf, 576.0]        6       19        6       19   \n",
       "41  2024.03.18~03.24  (576.0, 610.0]       82      252       79      252   \n",
       "42  2024.03.18~03.24  (610.0, 620.0]       74      184       73      184   \n",
       "43  2024.03.18~03.24    (620.0, inf]       52      165       49      165   \n",
       "\n",
       "         pd1       cpd  \n",
       "0   0.000000  0.000000  \n",
       "1   1.000000  1.000000  \n",
       "2   0.000000  0.000000  \n",
       "3        NaN       NaN  \n",
       "4   0.470588  0.358289  \n",
       "5   0.419129  0.363142  \n",
       "6   0.351268  0.308224  \n",
       "7   0.275142  0.178368  \n",
       "8   0.500000  0.460526  \n",
       "9   0.423649  0.354738  \n",
       "10  0.285442  0.250238  \n",
       "11  0.240810  0.177044  \n",
       "12  0.500931  0.433892  \n",
       "13  0.405045  0.354599  \n",
       "14  0.305785  0.256198  \n",
       "15  0.237104  0.178281  \n",
       "16  0.368932  0.300971  \n",
       "17  0.345238  0.284864  \n",
       "18  0.250951  0.229087  \n",
       "19  0.241107  0.213439  \n",
       "20  0.492063  0.317460  \n",
       "21  0.385533  0.284116  \n",
       "22  0.298201  0.256213  \n",
       "23  0.344063  0.292561  \n",
       "24  0.461538  0.448718  \n",
       "25  0.288633  0.213921  \n",
       "26  0.369803  0.326039  \n",
       "27  0.344725  0.292719  \n",
       "28  0.333333  0.180556  \n",
       "29  0.273958  0.193828  \n",
       "30  0.326154  0.281538  \n",
       "31  0.303519  0.233138  \n",
       "32  0.280702  0.210526  \n",
       "33  0.235392  0.186144  \n",
       "34  0.330508  0.286441  \n",
       "35  0.297583  0.243202  \n",
       "36  0.250000  0.227273  \n",
       "37  0.325850  0.277742  \n",
       "38  0.333775  0.307285  \n",
       "39  0.280682  0.242045  \n",
       "40  0.315789  0.315789  \n",
       "41  0.325397  0.313492  \n",
       "42  0.402174  0.396739  \n",
       "43  0.315152  0.296970  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']>=1) & (df['scorev3']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-01-09\"))\n",
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev3_bin']\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a2d074c5",
   "metadata": {},
   "source": [
    "# scorev4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "c3453a65",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-06T01:54:03.853586Z",
     "start_time": "2024-02-06T01:54:03.425340Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev4_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 530.0]</td>\n",
       "      <td>1554</td>\n",
       "      <td>1542</td>\n",
       "      <td>3096</td>\n",
       "      <td>0.205755</td>\n",
       "      <td>0.498062</td>\n",
       "      <td>-0.114794</td>\n",
       "      <td>1.061371</td>\n",
       "      <td>0.023792</td>\n",
       "      <td>0.005107</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev4_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(530.0, 560.0]</td>\n",
       "      <td>3245</td>\n",
       "      <td>2860</td>\n",
       "      <td>6105</td>\n",
       "      <td>0.405729</td>\n",
       "      <td>0.468468</td>\n",
       "      <td>0.003183</td>\n",
       "      <td>0.998307</td>\n",
       "      <td>0.022498</td>\n",
       "      <td>0.005107</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev4_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(560.0, 580.0]</td>\n",
       "      <td>1563</td>\n",
       "      <td>1304</td>\n",
       "      <td>2867</td>\n",
       "      <td>0.190536</td>\n",
       "      <td>0.454831</td>\n",
       "      <td>0.057763</td>\n",
       "      <td>0.969245</td>\n",
       "      <td>0.011457</td>\n",
       "      <td>0.005107</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev4_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(580.0, 600.0]</td>\n",
       "      <td>1112</td>\n",
       "      <td>974</td>\n",
       "      <td>2086</td>\n",
       "      <td>0.138632</td>\n",
       "      <td>0.466922</td>\n",
       "      <td>0.009334</td>\n",
       "      <td>0.995012</td>\n",
       "      <td>0.010154</td>\n",
       "      <td>0.005107</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>scorev4_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(600.0, inf]</td>\n",
       "      <td>512</td>\n",
       "      <td>381</td>\n",
       "      <td>893</td>\n",
       "      <td>0.059347</td>\n",
       "      <td>0.426652</td>\n",
       "      <td>0.169536</td>\n",
       "      <td>0.909195</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.005107</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev4_bin  def_pd1   (-inf, 530.0]      1554      1542   3096   \n",
       "1  scorev4_bin  def_pd1  (530.0, 560.0]      3245      2860   6105   \n",
       "2  scorev4_bin  def_pd1  (560.0, 580.0]      1563      1304   2867   \n",
       "3  scorev4_bin  def_pd1  (580.0, 600.0]      1112       974   2086   \n",
       "4  scorev4_bin  def_pd1    (600.0, inf]       512       381    893   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.205755       0.498062 -0.114794  1.061371  0.023792  0.005107  \n",
       "1    0.405729       0.468468  0.003183  0.998307  0.022498  0.005107  \n",
       "2    0.190536       0.454831  0.057763  0.969245  0.011457  0.005107  \n",
       "3    0.138632       0.466922  0.009334  0.995012  0.010154  0.005107  \n",
       "4    0.059347       0.426652  0.169536  0.909195  0.000000  0.005107  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']>0)&(df['scorev4']>0)\n",
    "df['scorev4_bin'] = pd.cut(df['scorev4'],[-np.inf,530,560,580,600 ,np.inf])\n",
    "kit.univerate(df[condition],'scorev4_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "6ba38322",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-06T01:54:04.692693Z",
     "start_time": "2024-02-06T01:54:03.427170Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_19861/1249607330.py:63: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.\n",
      "  grouped = data.groupby(group)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>repayment_week</th>\n",
       "      <th>scorev4_bin</th>\n",
       "      <th>def_pd1</th>\n",
       "      <th>agr_pd1</th>\n",
       "      <th>def_cpd</th>\n",
       "      <th>agr_cpd</th>\n",
       "      <th>pd1</th>\n",
       "      <th>cpd</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2022.12.26~01.01</td>\n",
       "      <td>(-inf, 530.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2022.12.26~01.01</td>\n",
       "      <td>(530.0, 560.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2022.12.26~01.01</td>\n",
       "      <td>(560.0, 580.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2022.12.26~01.01</td>\n",
       "      <td>(580.0, 600.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2022.12.26~01.01</td>\n",
       "      <td>(600.0, inf]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2023.01.02~01.08</td>\n",
       "      <td>(-inf, 530.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2023.01.02~01.08</td>\n",
       "      <td>(530.0, 560.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2023.01.02~01.08</td>\n",
       "      <td>(560.0, 580.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2023.01.02~01.08</td>\n",
       "      <td>(580.0, 600.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2023.01.02~01.08</td>\n",
       "      <td>(600.0, inf]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(-inf, 530.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(530.0, 560.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(560.0, 580.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(580.0, 600.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.666667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2023.12.25~12.31</td>\n",
       "      <td>(600.0, inf]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(-inf, 530.0]</td>\n",
       "      <td>438</td>\n",
       "      <td>866</td>\n",
       "      <td>403</td>\n",
       "      <td>866</td>\n",
       "      <td>0.505774</td>\n",
       "      <td>0.465358</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(530.0, 560.0]</td>\n",
       "      <td>530</td>\n",
       "      <td>1070</td>\n",
       "      <td>507</td>\n",
       "      <td>1070</td>\n",
       "      <td>0.495327</td>\n",
       "      <td>0.473832</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(560.0, 580.0]</td>\n",
       "      <td>152</td>\n",
       "      <td>342</td>\n",
       "      <td>143</td>\n",
       "      <td>342</td>\n",
       "      <td>0.444444</td>\n",
       "      <td>0.418129</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(580.0, 600.0]</td>\n",
       "      <td>114</td>\n",
       "      <td>262</td>\n",
       "      <td>100</td>\n",
       "      <td>262</td>\n",
       "      <td>0.435115</td>\n",
       "      <td>0.381679</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2024.01.01~01.07</td>\n",
       "      <td>(600.0, inf]</td>\n",
       "      <td>37</td>\n",
       "      <td>102</td>\n",
       "      <td>32</td>\n",
       "      <td>102</td>\n",
       "      <td>0.362745</td>\n",
       "      <td>0.313725</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(-inf, 530.0]</td>\n",
       "      <td>272</td>\n",
       "      <td>598</td>\n",
       "      <td>257</td>\n",
       "      <td>598</td>\n",
       "      <td>0.454849</td>\n",
       "      <td>0.429766</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(530.0, 560.0]</td>\n",
       "      <td>655</td>\n",
       "      <td>1412</td>\n",
       "      <td>617</td>\n",
       "      <td>1412</td>\n",
       "      <td>0.463881</td>\n",
       "      <td>0.436969</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(560.0, 580.0]</td>\n",
       "      <td>306</td>\n",
       "      <td>789</td>\n",
       "      <td>277</td>\n",
       "      <td>789</td>\n",
       "      <td>0.387833</td>\n",
       "      <td>0.351077</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(580.0, 600.0]</td>\n",
       "      <td>239</td>\n",
       "      <td>517</td>\n",
       "      <td>230</td>\n",
       "      <td>517</td>\n",
       "      <td>0.462282</td>\n",
       "      <td>0.444874</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2024.01.08~01.14</td>\n",
       "      <td>(600.0, inf]</td>\n",
       "      <td>90</td>\n",
       "      <td>202</td>\n",
       "      <td>85</td>\n",
       "      <td>202</td>\n",
       "      <td>0.445545</td>\n",
       "      <td>0.420792</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(-inf, 530.0]</td>\n",
       "      <td>176</td>\n",
       "      <td>353</td>\n",
       "      <td>164</td>\n",
       "      <td>353</td>\n",
       "      <td>0.498584</td>\n",
       "      <td>0.464589</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(530.0, 560.0]</td>\n",
       "      <td>518</td>\n",
       "      <td>1207</td>\n",
       "      <td>486</td>\n",
       "      <td>1207</td>\n",
       "      <td>0.429163</td>\n",
       "      <td>0.402651</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(560.0, 580.0]</td>\n",
       "      <td>436</td>\n",
       "      <td>776</td>\n",
       "      <td>418</td>\n",
       "      <td>776</td>\n",
       "      <td>0.561856</td>\n",
       "      <td>0.538660</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(580.0, 600.0]</td>\n",
       "      <td>254</td>\n",
       "      <td>557</td>\n",
       "      <td>247</td>\n",
       "      <td>557</td>\n",
       "      <td>0.456014</td>\n",
       "      <td>0.443447</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(600.0, inf]</td>\n",
       "      <td>123</td>\n",
       "      <td>244</td>\n",
       "      <td>117</td>\n",
       "      <td>244</td>\n",
       "      <td>0.504098</td>\n",
       "      <td>0.479508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(-inf, 530.0]</td>\n",
       "      <td>390</td>\n",
       "      <td>767</td>\n",
       "      <td>371</td>\n",
       "      <td>767</td>\n",
       "      <td>0.508475</td>\n",
       "      <td>0.483703</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(530.0, 560.0]</td>\n",
       "      <td>720</td>\n",
       "      <td>1455</td>\n",
       "      <td>675</td>\n",
       "      <td>1455</td>\n",
       "      <td>0.494845</td>\n",
       "      <td>0.463918</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(560.0, 580.0]</td>\n",
       "      <td>279</td>\n",
       "      <td>624</td>\n",
       "      <td>264</td>\n",
       "      <td>624</td>\n",
       "      <td>0.447115</td>\n",
       "      <td>0.423077</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(580.0, 600.0]</td>\n",
       "      <td>227</td>\n",
       "      <td>463</td>\n",
       "      <td>219</td>\n",
       "      <td>463</td>\n",
       "      <td>0.490281</td>\n",
       "      <td>0.473002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(600.0, inf]</td>\n",
       "      <td>80</td>\n",
       "      <td>211</td>\n",
       "      <td>77</td>\n",
       "      <td>211</td>\n",
       "      <td>0.379147</td>\n",
       "      <td>0.364929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(-inf, 530.0]</td>\n",
       "      <td>266</td>\n",
       "      <td>512</td>\n",
       "      <td>263</td>\n",
       "      <td>512</td>\n",
       "      <td>0.519531</td>\n",
       "      <td>0.513672</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(530.0, 560.0]</td>\n",
       "      <td>437</td>\n",
       "      <td>961</td>\n",
       "      <td>424</td>\n",
       "      <td>961</td>\n",
       "      <td>0.454735</td>\n",
       "      <td>0.441207</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(560.0, 580.0]</td>\n",
       "      <td>131</td>\n",
       "      <td>336</td>\n",
       "      <td>125</td>\n",
       "      <td>336</td>\n",
       "      <td>0.389881</td>\n",
       "      <td>0.372024</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(580.0, 600.0]</td>\n",
       "      <td>138</td>\n",
       "      <td>282</td>\n",
       "      <td>121</td>\n",
       "      <td>282</td>\n",
       "      <td>0.489362</td>\n",
       "      <td>0.429078</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(600.0, inf]</td>\n",
       "      <td>51</td>\n",
       "      <td>134</td>\n",
       "      <td>50</td>\n",
       "      <td>134</td>\n",
       "      <td>0.380597</td>\n",
       "      <td>0.373134</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      repayment_week     scorev4_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n",
       "0   2022.12.26~01.01   (-inf, 530.0]        0        0        0        0   \n",
       "1   2022.12.26~01.01  (530.0, 560.0]        0        0        0        0   \n",
       "2   2022.12.26~01.01  (560.0, 580.0]        0        0        0        0   \n",
       "3   2022.12.26~01.01  (580.0, 600.0]        0        1        0        1   \n",
       "4   2022.12.26~01.01    (600.0, inf]        0        0        0        0   \n",
       "5   2023.01.02~01.08   (-inf, 530.0]        0        0        0        0   \n",
       "6   2023.01.02~01.08  (530.0, 560.0]        0        0        0        0   \n",
       "7   2023.01.02~01.08  (560.0, 580.0]        0        0        0        0   \n",
       "8   2023.01.02~01.08  (580.0, 600.0]        0        1        0        1   \n",
       "9   2023.01.02~01.08    (600.0, inf]        0        0        0        0   \n",
       "10  2023.12.25~12.31   (-inf, 530.0]        0        0        0        0   \n",
       "11  2023.12.25~12.31  (530.0, 560.0]        0        0        0        0   \n",
       "12  2023.12.25~12.31  (560.0, 580.0]        0        0        0        0   \n",
       "13  2023.12.25~12.31  (580.0, 600.0]        2        3        2        3   \n",
       "14  2023.12.25~12.31    (600.0, inf]        0        0        0        0   \n",
       "15  2024.01.01~01.07   (-inf, 530.0]      438      866      403      866   \n",
       "16  2024.01.01~01.07  (530.0, 560.0]      530     1070      507     1070   \n",
       "17  2024.01.01~01.07  (560.0, 580.0]      152      342      143      342   \n",
       "18  2024.01.01~01.07  (580.0, 600.0]      114      262      100      262   \n",
       "19  2024.01.01~01.07    (600.0, inf]       37      102       32      102   \n",
       "20  2024.01.08~01.14   (-inf, 530.0]      272      598      257      598   \n",
       "21  2024.01.08~01.14  (530.0, 560.0]      655     1412      617     1412   \n",
       "22  2024.01.08~01.14  (560.0, 580.0]      306      789      277      789   \n",
       "23  2024.01.08~01.14  (580.0, 600.0]      239      517      230      517   \n",
       "24  2024.01.08~01.14    (600.0, inf]       90      202       85      202   \n",
       "25  2024.01.15~01.21   (-inf, 530.0]      176      353      164      353   \n",
       "26  2024.01.15~01.21  (530.0, 560.0]      518     1207      486     1207   \n",
       "27  2024.01.15~01.21  (560.0, 580.0]      436      776      418      776   \n",
       "28  2024.01.15~01.21  (580.0, 600.0]      254      557      247      557   \n",
       "29  2024.01.15~01.21    (600.0, inf]      123      244      117      244   \n",
       "30  2024.01.22~01.28   (-inf, 530.0]      390      767      371      767   \n",
       "31  2024.01.22~01.28  (530.0, 560.0]      720     1455      675     1455   \n",
       "32  2024.01.22~01.28  (560.0, 580.0]      279      624      264      624   \n",
       "33  2024.01.22~01.28  (580.0, 600.0]      227      463      219      463   \n",
       "34  2024.01.22~01.28    (600.0, inf]       80      211       77      211   \n",
       "35  2024.01.29~02.04   (-inf, 530.0]      266      512      263      512   \n",
       "36  2024.01.29~02.04  (530.0, 560.0]      437      961      424      961   \n",
       "37  2024.01.29~02.04  (560.0, 580.0]      131      336      125      336   \n",
       "38  2024.01.29~02.04  (580.0, 600.0]      138      282      121      282   \n",
       "39  2024.01.29~02.04    (600.0, inf]       51      134       50      134   \n",
       "\n",
       "         pd1       cpd  \n",
       "0        NaN       NaN  \n",
       "1        NaN       NaN  \n",
       "2        NaN       NaN  \n",
       "3   0.000000  0.000000  \n",
       "4        NaN       NaN  \n",
       "5        NaN       NaN  \n",
       "6        NaN       NaN  \n",
       "7        NaN       NaN  \n",
       "8   0.000000  0.000000  \n",
       "9        NaN       NaN  \n",
       "10       NaN       NaN  \n",
       "11       NaN       NaN  \n",
       "12       NaN       NaN  \n",
       "13  0.666667  0.666667  \n",
       "14       NaN       NaN  \n",
       "15  0.505774  0.465358  \n",
       "16  0.495327  0.473832  \n",
       "17  0.444444  0.418129  \n",
       "18  0.435115  0.381679  \n",
       "19  0.362745  0.313725  \n",
       "20  0.454849  0.429766  \n",
       "21  0.463881  0.436969  \n",
       "22  0.387833  0.351077  \n",
       "23  0.462282  0.444874  \n",
       "24  0.445545  0.420792  \n",
       "25  0.498584  0.464589  \n",
       "26  0.429163  0.402651  \n",
       "27  0.561856  0.538660  \n",
       "28  0.456014  0.443447  \n",
       "29  0.504098  0.479508  \n",
       "30  0.508475  0.483703  \n",
       "31  0.494845  0.463918  \n",
       "32  0.447115  0.423077  \n",
       "33  0.490281  0.473002  \n",
       "34  0.379147  0.364929  \n",
       "35  0.519531  0.513672  \n",
       "36  0.454735  0.441207  \n",
       "37  0.389881  0.372024  \n",
       "38  0.489362  0.429078  \n",
       "39  0.380597  0.373134  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev4_bin']\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1d29e768",
   "metadata": {},
   "source": [
    "# scorev5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "df2f355d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:43:38.864699Z",
     "start_time": "2024-03-20T06:43:38.803991Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev5_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>382</td>\n",
       "      <td>347</td>\n",
       "      <td>729</td>\n",
       "      <td>0.239645</td>\n",
       "      <td>0.475995</td>\n",
       "      <td>-0.322859</td>\n",
       "      <td>1.200643</td>\n",
       "      <td>0.079667</td>\n",
       "      <td>0.136961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev5_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>1140</td>\n",
       "      <td>771</td>\n",
       "      <td>1911</td>\n",
       "      <td>0.628205</td>\n",
       "      <td>0.403454</td>\n",
       "      <td>-0.029139</td>\n",
       "      <td>1.017667</td>\n",
       "      <td>0.098055</td>\n",
       "      <td>0.136961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev5_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>150</td>\n",
       "      <td>63</td>\n",
       "      <td>213</td>\n",
       "      <td>0.070020</td>\n",
       "      <td>0.295775</td>\n",
       "      <td>0.440424</td>\n",
       "      <td>0.746058</td>\n",
       "      <td>0.068595</td>\n",
       "      <td>0.136961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev5_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>164</td>\n",
       "      <td>25</td>\n",
       "      <td>189</td>\n",
       "      <td>0.062130</td>\n",
       "      <td>0.132275</td>\n",
       "      <td>1.424731</td>\n",
       "      <td>0.333649</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.136961</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev5_bin  def_pd1   (-inf, 550.0]       382       347    729   \n",
       "1  scorev5_bin  def_pd1  (550.0, 670.0]      1140       771   1911   \n",
       "2  scorev5_bin  def_pd1  (670.0, 710.0]       150        63    213   \n",
       "3  scorev5_bin  def_pd1    (710.0, inf]       164        25    189   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.239645       0.475995 -0.322859  1.200643  0.079667  0.136961  \n",
       "1    0.628205       0.403454 -0.029139  1.017667  0.098055  0.136961  \n",
       "2    0.070020       0.295775  0.440424  0.746058  0.068595  0.136961  \n",
       "3    0.062130       0.132275  1.424731  0.333649  0.000000  0.136961  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='ios')&(df['new_old_user_status']==0)&(df['scorev5']>0) & (df['apply_time']>=pd.to_datetime(\"2024-01-30\"))\n",
    "df['scorev5_bin'] = pd.cut(df['scorev5'],[-np.inf,550,670,710 ,np.inf])\n",
    "kit.univerate(df[condition],'scorev5_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "d191f434190b9a84",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:43:42.118796Z",
     "start_time": "2024-03-20T06:43:42.099135Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_27965/1208034288.py:63: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.\n",
      "  grouped = data.groupby(group)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>repayment_week</th>\n",
       "      <th>scorev5_bin</th>\n",
       "      <th>def_pd1</th>\n",
       "      <th>agr_pd1</th>\n",
       "      <th>def_cpd</th>\n",
       "      <th>agr_cpd</th>\n",
       "      <th>pd1</th>\n",
       "      <th>cpd</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>50</td>\n",
       "      <td>95</td>\n",
       "      <td>46</td>\n",
       "      <td>95</td>\n",
       "      <td>0.526316</td>\n",
       "      <td>0.484211</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>122</td>\n",
       "      <td>305</td>\n",
       "      <td>113</td>\n",
       "      <td>305</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>0.370492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>7</td>\n",
       "      <td>30</td>\n",
       "      <td>6</td>\n",
       "      <td>30</td>\n",
       "      <td>0.233333</td>\n",
       "      <td>0.200000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>3</td>\n",
       "      <td>31</td>\n",
       "      <td>3</td>\n",
       "      <td>31</td>\n",
       "      <td>0.096774</td>\n",
       "      <td>0.096774</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>47</td>\n",
       "      <td>114</td>\n",
       "      <td>41</td>\n",
       "      <td>114</td>\n",
       "      <td>0.412281</td>\n",
       "      <td>0.359649</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>108</td>\n",
       "      <td>250</td>\n",
       "      <td>97</td>\n",
       "      <td>250</td>\n",
       "      <td>0.432000</td>\n",
       "      <td>0.388000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>10</td>\n",
       "      <td>37</td>\n",
       "      <td>9</td>\n",
       "      <td>37</td>\n",
       "      <td>0.270270</td>\n",
       "      <td>0.243243</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>5</td>\n",
       "      <td>29</td>\n",
       "      <td>4</td>\n",
       "      <td>29</td>\n",
       "      <td>0.172414</td>\n",
       "      <td>0.137931</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>52</td>\n",
       "      <td>111</td>\n",
       "      <td>47</td>\n",
       "      <td>111</td>\n",
       "      <td>0.468468</td>\n",
       "      <td>0.423423</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>144</td>\n",
       "      <td>319</td>\n",
       "      <td>130</td>\n",
       "      <td>319</td>\n",
       "      <td>0.451411</td>\n",
       "      <td>0.407524</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>16</td>\n",
       "      <td>35</td>\n",
       "      <td>14</td>\n",
       "      <td>35</td>\n",
       "      <td>0.457143</td>\n",
       "      <td>0.400000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>4</td>\n",
       "      <td>27</td>\n",
       "      <td>2</td>\n",
       "      <td>27</td>\n",
       "      <td>0.148148</td>\n",
       "      <td>0.074074</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>52</td>\n",
       "      <td>113</td>\n",
       "      <td>47</td>\n",
       "      <td>113</td>\n",
       "      <td>0.460177</td>\n",
       "      <td>0.415929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>106</td>\n",
       "      <td>297</td>\n",
       "      <td>94</td>\n",
       "      <td>297</td>\n",
       "      <td>0.356902</td>\n",
       "      <td>0.316498</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>8</td>\n",
       "      <td>23</td>\n",
       "      <td>6</td>\n",
       "      <td>23</td>\n",
       "      <td>0.347826</td>\n",
       "      <td>0.260870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>5</td>\n",
       "      <td>35</td>\n",
       "      <td>5</td>\n",
       "      <td>35</td>\n",
       "      <td>0.142857</td>\n",
       "      <td>0.142857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>40</td>\n",
       "      <td>106</td>\n",
       "      <td>35</td>\n",
       "      <td>106</td>\n",
       "      <td>0.377358</td>\n",
       "      <td>0.330189</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>113</td>\n",
       "      <td>304</td>\n",
       "      <td>97</td>\n",
       "      <td>304</td>\n",
       "      <td>0.371711</td>\n",
       "      <td>0.319079</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>9</td>\n",
       "      <td>35</td>\n",
       "      <td>8</td>\n",
       "      <td>35</td>\n",
       "      <td>0.257143</td>\n",
       "      <td>0.228571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>3</td>\n",
       "      <td>20</td>\n",
       "      <td>3</td>\n",
       "      <td>20</td>\n",
       "      <td>0.150000</td>\n",
       "      <td>0.150000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>80</td>\n",
       "      <td>145</td>\n",
       "      <td>76</td>\n",
       "      <td>145</td>\n",
       "      <td>0.551724</td>\n",
       "      <td>0.524138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>128</td>\n",
       "      <td>321</td>\n",
       "      <td>122</td>\n",
       "      <td>321</td>\n",
       "      <td>0.398754</td>\n",
       "      <td>0.380062</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>9</td>\n",
       "      <td>37</td>\n",
       "      <td>9</td>\n",
       "      <td>37</td>\n",
       "      <td>0.243243</td>\n",
       "      <td>0.243243</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>5</td>\n",
       "      <td>40</td>\n",
       "      <td>5</td>\n",
       "      <td>40</td>\n",
       "      <td>0.125000</td>\n",
       "      <td>0.125000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>26</td>\n",
       "      <td>45</td>\n",
       "      <td>26</td>\n",
       "      <td>45</td>\n",
       "      <td>0.577778</td>\n",
       "      <td>0.577778</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>50</td>\n",
       "      <td>115</td>\n",
       "      <td>49</td>\n",
       "      <td>115</td>\n",
       "      <td>0.434783</td>\n",
       "      <td>0.426087</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>4</td>\n",
       "      <td>16</td>\n",
       "      <td>4</td>\n",
       "      <td>16</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>0.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      repayment_week     scorev5_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n",
       "0   2024.02.05~02.11   (-inf, 550.0]       50       95       46       95   \n",
       "1   2024.02.05~02.11  (550.0, 670.0]      122      305      113      305   \n",
       "2   2024.02.05~02.11  (670.0, 710.0]        7       30        6       30   \n",
       "3   2024.02.05~02.11    (710.0, inf]        3       31        3       31   \n",
       "4   2024.02.12~02.18   (-inf, 550.0]       47      114       41      114   \n",
       "5   2024.02.12~02.18  (550.0, 670.0]      108      250       97      250   \n",
       "6   2024.02.12~02.18  (670.0, 710.0]       10       37        9       37   \n",
       "7   2024.02.12~02.18    (710.0, inf]        5       29        4       29   \n",
       "8   2024.02.19~02.25   (-inf, 550.0]       52      111       47      111   \n",
       "9   2024.02.19~02.25  (550.0, 670.0]      144      319      130      319   \n",
       "10  2024.02.19~02.25  (670.0, 710.0]       16       35       14       35   \n",
       "11  2024.02.19~02.25    (710.0, inf]        4       27        2       27   \n",
       "12  2024.02.26~03.03   (-inf, 550.0]       52      113       47      113   \n",
       "13  2024.02.26~03.03  (550.0, 670.0]      106      297       94      297   \n",
       "14  2024.02.26~03.03  (670.0, 710.0]        8       23        6       23   \n",
       "15  2024.02.26~03.03    (710.0, inf]        5       35        5       35   \n",
       "16  2024.03.04~03.10   (-inf, 550.0]       40      106       35      106   \n",
       "17  2024.03.04~03.10  (550.0, 670.0]      113      304       97      304   \n",
       "18  2024.03.04~03.10  (670.0, 710.0]        9       35        8       35   \n",
       "19  2024.03.04~03.10    (710.0, inf]        3       20        3       20   \n",
       "20  2024.03.11~03.17   (-inf, 550.0]       80      145       76      145   \n",
       "21  2024.03.11~03.17  (550.0, 670.0]      128      321      122      321   \n",
       "22  2024.03.11~03.17  (670.0, 710.0]        9       37        9       37   \n",
       "23  2024.03.11~03.17    (710.0, inf]        5       40        5       40   \n",
       "24  2024.03.18~03.24   (-inf, 550.0]       26       45       26       45   \n",
       "25  2024.03.18~03.24  (550.0, 670.0]       50      115       49      115   \n",
       "26  2024.03.18~03.24  (670.0, 710.0]        4       16        4       16   \n",
       "27  2024.03.18~03.24    (710.0, inf]        0        7        0        7   \n",
       "\n",
       "         pd1       cpd  \n",
       "0   0.526316  0.484211  \n",
       "1   0.400000  0.370492  \n",
       "2   0.233333  0.200000  \n",
       "3   0.096774  0.096774  \n",
       "4   0.412281  0.359649  \n",
       "5   0.432000  0.388000  \n",
       "6   0.270270  0.243243  \n",
       "7   0.172414  0.137931  \n",
       "8   0.468468  0.423423  \n",
       "9   0.451411  0.407524  \n",
       "10  0.457143  0.400000  \n",
       "11  0.148148  0.074074  \n",
       "12  0.460177  0.415929  \n",
       "13  0.356902  0.316498  \n",
       "14  0.347826  0.260870  \n",
       "15  0.142857  0.142857  \n",
       "16  0.377358  0.330189  \n",
       "17  0.371711  0.319079  \n",
       "18  0.257143  0.228571  \n",
       "19  0.150000  0.150000  \n",
       "20  0.551724  0.524138  \n",
       "21  0.398754  0.380062  \n",
       "22  0.243243  0.243243  \n",
       "23  0.125000  0.125000  \n",
       "24  0.577778  0.577778  \n",
       "25  0.434783  0.426087  \n",
       "26  0.250000  0.250000  \n",
       "27  0.000000  0.000000  "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev5_bin']\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a67c4c2a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "1fea229f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-11T07:37:26.533207Z",
     "start_time": "2024-03-11T07:37:26.268041Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev5_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>950</td>\n",
       "      <td>854</td>\n",
       "      <td>1804</td>\n",
       "      <td>0.166883</td>\n",
       "      <td>0.473392</td>\n",
       "      <td>-0.388133</td>\n",
       "      <td>1.251497</td>\n",
       "      <td>0.067505</td>\n",
       "      <td>0.075652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev5_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>3959</td>\n",
       "      <td>2512</td>\n",
       "      <td>6471</td>\n",
       "      <td>0.598612</td>\n",
       "      <td>0.388193</td>\n",
       "      <td>-0.041955</td>\n",
       "      <td>1.026259</td>\n",
       "      <td>0.092787</td>\n",
       "      <td>0.075652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev5_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>742</td>\n",
       "      <td>371</td>\n",
       "      <td>1113</td>\n",
       "      <td>0.102960</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.194267</td>\n",
       "      <td>0.881226</td>\n",
       "      <td>0.073118</td>\n",
       "      <td>0.075652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev5_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>1070</td>\n",
       "      <td>352</td>\n",
       "      <td>1422</td>\n",
       "      <td>0.131545</td>\n",
       "      <td>0.247539</td>\n",
       "      <td>0.609558</td>\n",
       "      <td>0.654413</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.075652</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev5_bin  def_pd1   (-inf, 550.0]       950       854   1804   \n",
       "1  scorev5_bin  def_pd1  (550.0, 670.0]      3959      2512   6471   \n",
       "2  scorev5_bin  def_pd1  (670.0, 710.0]       742       371   1113   \n",
       "3  scorev5_bin  def_pd1    (710.0, inf]      1070       352   1422   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.166883       0.473392 -0.388133  1.251497  0.067505  0.075652  \n",
       "1    0.598612       0.388193 -0.041955  1.026259  0.092787  0.075652  \n",
       "2    0.102960       0.333333  0.194267  0.881226  0.073118  0.075652  \n",
       "3    0.131545       0.247539  0.609558  0.654413  0.000000  0.075652  "
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='ios')&(df['new_old_user_status']>0)&(df['scorev5']>0) & (df['apply_time']>=pd.to_datetime(\"2024-01-30\"))\n",
    "df['scorev5_bin'] = pd.cut(df['scorev5'],[-np.inf,550,670,710 ,np.inf])\n",
    "kit.univerate(df[condition],'scorev5_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "779f4589",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-11T07:37:50.928370Z",
     "start_time": "2024-03-11T07:37:50.671574Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_21153/1208034288.py:63: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.\n",
      "  grouped = data.groupby(group)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>repayment_week</th>\n",
       "      <th>scorev5_bin</th>\n",
       "      <th>def_pd1</th>\n",
       "      <th>agr_pd1</th>\n",
       "      <th>def_cpd</th>\n",
       "      <th>agr_cpd</th>\n",
       "      <th>pd1</th>\n",
       "      <th>cpd</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>171</td>\n",
       "      <td>383</td>\n",
       "      <td>146</td>\n",
       "      <td>383</td>\n",
       "      <td>0.446475</td>\n",
       "      <td>0.381201</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>546</td>\n",
       "      <td>1450</td>\n",
       "      <td>509</td>\n",
       "      <td>1450</td>\n",
       "      <td>0.376552</td>\n",
       "      <td>0.351034</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>80</td>\n",
       "      <td>259</td>\n",
       "      <td>75</td>\n",
       "      <td>259</td>\n",
       "      <td>0.308880</td>\n",
       "      <td>0.289575</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>85</td>\n",
       "      <td>252</td>\n",
       "      <td>64</td>\n",
       "      <td>252</td>\n",
       "      <td>0.337302</td>\n",
       "      <td>0.253968</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>154</td>\n",
       "      <td>296</td>\n",
       "      <td>152</td>\n",
       "      <td>296</td>\n",
       "      <td>0.520270</td>\n",
       "      <td>0.513514</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>556</td>\n",
       "      <td>1272</td>\n",
       "      <td>505</td>\n",
       "      <td>1272</td>\n",
       "      <td>0.437107</td>\n",
       "      <td>0.397013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>64</td>\n",
       "      <td>170</td>\n",
       "      <td>52</td>\n",
       "      <td>170</td>\n",
       "      <td>0.376471</td>\n",
       "      <td>0.305882</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>57</td>\n",
       "      <td>249</td>\n",
       "      <td>48</td>\n",
       "      <td>249</td>\n",
       "      <td>0.228916</td>\n",
       "      <td>0.192771</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>162</td>\n",
       "      <td>323</td>\n",
       "      <td>138</td>\n",
       "      <td>323</td>\n",
       "      <td>0.501548</td>\n",
       "      <td>0.427245</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>507</td>\n",
       "      <td>1012</td>\n",
       "      <td>454</td>\n",
       "      <td>1012</td>\n",
       "      <td>0.500988</td>\n",
       "      <td>0.448617</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>87</td>\n",
       "      <td>203</td>\n",
       "      <td>75</td>\n",
       "      <td>203</td>\n",
       "      <td>0.428571</td>\n",
       "      <td>0.369458</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>75</td>\n",
       "      <td>253</td>\n",
       "      <td>60</td>\n",
       "      <td>253</td>\n",
       "      <td>0.296443</td>\n",
       "      <td>0.237154</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>174</td>\n",
       "      <td>385</td>\n",
       "      <td>166</td>\n",
       "      <td>385</td>\n",
       "      <td>0.451948</td>\n",
       "      <td>0.431169</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>423</td>\n",
       "      <td>1281</td>\n",
       "      <td>399</td>\n",
       "      <td>1281</td>\n",
       "      <td>0.330211</td>\n",
       "      <td>0.311475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>70</td>\n",
       "      <td>242</td>\n",
       "      <td>61</td>\n",
       "      <td>242</td>\n",
       "      <td>0.289256</td>\n",
       "      <td>0.252066</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>61</td>\n",
       "      <td>323</td>\n",
       "      <td>55</td>\n",
       "      <td>323</td>\n",
       "      <td>0.188854</td>\n",
       "      <td>0.170279</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(-inf, 550.0]</td>\n",
       "      <td>193</td>\n",
       "      <td>417</td>\n",
       "      <td>190</td>\n",
       "      <td>417</td>\n",
       "      <td>0.462830</td>\n",
       "      <td>0.455635</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(550.0, 670.0]</td>\n",
       "      <td>480</td>\n",
       "      <td>1456</td>\n",
       "      <td>460</td>\n",
       "      <td>1456</td>\n",
       "      <td>0.329670</td>\n",
       "      <td>0.315934</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(670.0, 710.0]</td>\n",
       "      <td>70</td>\n",
       "      <td>239</td>\n",
       "      <td>57</td>\n",
       "      <td>239</td>\n",
       "      <td>0.292887</td>\n",
       "      <td>0.238494</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(710.0, inf]</td>\n",
       "      <td>74</td>\n",
       "      <td>345</td>\n",
       "      <td>68</td>\n",
       "      <td>345</td>\n",
       "      <td>0.214493</td>\n",
       "      <td>0.197101</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      repayment_week     scorev5_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n",
       "0   2024.02.05~02.11   (-inf, 550.0]      171      383      146      383   \n",
       "1   2024.02.05~02.11  (550.0, 670.0]      546     1450      509     1450   \n",
       "2   2024.02.05~02.11  (670.0, 710.0]       80      259       75      259   \n",
       "3   2024.02.05~02.11    (710.0, inf]       85      252       64      252   \n",
       "4   2024.02.12~02.18   (-inf, 550.0]      154      296      152      296   \n",
       "5   2024.02.12~02.18  (550.0, 670.0]      556     1272      505     1272   \n",
       "6   2024.02.12~02.18  (670.0, 710.0]       64      170       52      170   \n",
       "7   2024.02.12~02.18    (710.0, inf]       57      249       48      249   \n",
       "8   2024.02.19~02.25   (-inf, 550.0]      162      323      138      323   \n",
       "9   2024.02.19~02.25  (550.0, 670.0]      507     1012      454     1012   \n",
       "10  2024.02.19~02.25  (670.0, 710.0]       87      203       75      203   \n",
       "11  2024.02.19~02.25    (710.0, inf]       75      253       60      253   \n",
       "12  2024.02.26~03.03   (-inf, 550.0]      174      385      166      385   \n",
       "13  2024.02.26~03.03  (550.0, 670.0]      423     1281      399     1281   \n",
       "14  2024.02.26~03.03  (670.0, 710.0]       70      242       61      242   \n",
       "15  2024.02.26~03.03    (710.0, inf]       61      323       55      323   \n",
       "16  2024.03.04~03.10   (-inf, 550.0]      193      417      190      417   \n",
       "17  2024.03.04~03.10  (550.0, 670.0]      480     1456      460     1456   \n",
       "18  2024.03.04~03.10  (670.0, 710.0]       70      239       57      239   \n",
       "19  2024.03.04~03.10    (710.0, inf]       74      345       68      345   \n",
       "\n",
       "         pd1       cpd  \n",
       "0   0.446475  0.381201  \n",
       "1   0.376552  0.351034  \n",
       "2   0.308880  0.289575  \n",
       "3   0.337302  0.253968  \n",
       "4   0.520270  0.513514  \n",
       "5   0.437107  0.397013  \n",
       "6   0.376471  0.305882  \n",
       "7   0.228916  0.192771  \n",
       "8   0.501548  0.427245  \n",
       "9   0.500988  0.448617  \n",
       "10  0.428571  0.369458  \n",
       "11  0.296443  0.237154  \n",
       "12  0.451948  0.431169  \n",
       "13  0.330211  0.311475  \n",
       "14  0.289256  0.252066  \n",
       "15  0.188854  0.170279  \n",
       "16  0.462830  0.455635  \n",
       "17  0.329670  0.315934  \n",
       "18  0.292887  0.238494  \n",
       "19  0.214493  0.197101  "
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev5_bin']\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cbd0b760",
   "metadata": {},
   "source": [
    "# scorev6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9d5c3eb77451fadb",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T04:21:26.488180Z",
     "start_time": "2024-04-01T04:21:26.478831Z"
    }
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'df' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[0;31mNameError\u001B[0m                                 Traceback (most recent call last)",
      "Cell \u001B[0;32mIn[3], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m condition\u001B[38;5;241m=\u001B[39m (\u001B[43mdf\u001B[49m[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mmerchant_id\u001B[39m\u001B[38;5;124m'\u001B[39m] \u001B[38;5;241m==\u001B[39m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mAM\u001B[39m\u001B[38;5;124m'\u001B[39m)\u001B[38;5;241m&\u001B[39m(df[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mdevice_type\u001B[39m\u001B[38;5;124m'\u001B[39m]\u001B[38;5;241m==\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mandroid\u001B[39m\u001B[38;5;124m'\u001B[39m)\u001B[38;5;241m&\u001B[39m(df[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mnew_old_user_status\u001B[39m\u001B[38;5;124m'\u001B[39m]\u001B[38;5;241m>\u001B[39m\u001B[38;5;241m0\u001B[39m)\u001B[38;5;241m&\u001B[39m(df[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mscorev6\u001B[39m\u001B[38;5;124m'\u001B[39m]\u001B[38;5;241m>\u001B[39m\u001B[38;5;241m0\u001B[39m) \u001B[38;5;241m&\u001B[39m (df[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mapply_time\u001B[39m\u001B[38;5;124m'\u001B[39m]\u001B[38;5;241m>\u001B[39m\u001B[38;5;241m=\u001B[39mpd\u001B[38;5;241m.\u001B[39mto_datetime(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124m2024-02-07\u001B[39m\u001B[38;5;124m\"\u001B[39m))\n\u001B[1;32m      2\u001B[0m df[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mscorev6_bin\u001B[39m\u001B[38;5;124m'\u001B[39m] \u001B[38;5;241m=\u001B[39m pd\u001B[38;5;241m.\u001B[39mcut(df[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mscorev6\u001B[39m\u001B[38;5;124m'\u001B[39m],[\u001B[38;5;241m-\u001B[39mnp\u001B[38;5;241m.\u001B[39minf,\u001B[38;5;241m575\u001B[39m,\u001B[38;5;241m577\u001B[39m,\u001B[38;5;241m580\u001B[39m,\u001B[38;5;241m585\u001B[39m,\u001B[38;5;241m590\u001B[39m,\u001B[38;5;241m600\u001B[39m ])\n\u001B[1;32m      3\u001B[0m kit\u001B[38;5;241m.\u001B[39muniverate(df[condition],\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mscorev6_bin\u001B[39m\u001B[38;5;124m'\u001B[39m,\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mdef_pd1\u001B[39m\u001B[38;5;124m'\u001B[39m) \n",
      "\u001B[0;31mNameError\u001B[0m: name 'df' is not defined"
     ]
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']>0)&(df['scorev6']>0) & (df['apply_time']>=pd.to_datetime(\"2024-02-07\"))\n",
    "df['scorev6_bin'] = pd.cut(df['scorev6'],[-np.inf,575,577,580,585,590,600 ])\n",
    "kit.univerate(df[condition],'scorev6_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "4ae34226dcb07d9e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-11T07:38:54.647752Z",
     "start_time": "2024-03-11T07:38:54.377031Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>repayment_week</th>\n",
       "      <th>def_pd1</th>\n",
       "      <th>agr_pd1</th>\n",
       "      <th>def_cpd</th>\n",
       "      <th>agr_cpd</th>\n",
       "      <th>pd1</th>\n",
       "      <th>cpd</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>230</td>\n",
       "      <td>619</td>\n",
       "      <td>199</td>\n",
       "      <td>619</td>\n",
       "      <td>0.371567</td>\n",
       "      <td>0.321486</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>259</td>\n",
       "      <td>828</td>\n",
       "      <td>229</td>\n",
       "      <td>828</td>\n",
       "      <td>0.312802</td>\n",
       "      <td>0.276570</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>300</td>\n",
       "      <td>927</td>\n",
       "      <td>280</td>\n",
       "      <td>927</td>\n",
       "      <td>0.323625</td>\n",
       "      <td>0.302050</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>330</td>\n",
       "      <td>943</td>\n",
       "      <td>323</td>\n",
       "      <td>943</td>\n",
       "      <td>0.349947</td>\n",
       "      <td>0.342524</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     repayment_week  def_pd1  agr_pd1  def_cpd  agr_cpd       pd1       cpd\n",
       "0  2024.02.12~02.18      230      619      199      619  0.371567  0.321486\n",
       "1  2024.02.19~02.25      259      828      229      828  0.312802  0.276570\n",
       "2  2024.02.26~03.03      300      927      280      927  0.323625  0.302050\n",
       "3  2024.03.04~03.10      330      943      323      943  0.349947  0.342524"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week']\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "64e412d3",
   "metadata": {},
   "source": [
    "# scorev7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "f922b139",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:46:04.016650Z",
     "start_time": "2024-03-20T06:46:03.956252Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(0.0, 541.0]</td>\n",
       "      <td>59</td>\n",
       "      <td>76</td>\n",
       "      <td>135</td>\n",
       "      <td>0.065693</td>\n",
       "      <td>0.562963</td>\n",
       "      <td>-0.491149</td>\n",
       "      <td>1.282582</td>\n",
       "      <td>0.033086</td>\n",
       "      <td>0.059166</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(541.0, 558.0]</td>\n",
       "      <td>138</td>\n",
       "      <td>161</td>\n",
       "      <td>299</td>\n",
       "      <td>0.145499</td>\n",
       "      <td>0.538462</td>\n",
       "      <td>-0.396925</td>\n",
       "      <td>1.226761</td>\n",
       "      <td>0.091891</td>\n",
       "      <td>0.059166</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(558.0, 584.0]</td>\n",
       "      <td>663</td>\n",
       "      <td>493</td>\n",
       "      <td>1156</td>\n",
       "      <td>0.562530</td>\n",
       "      <td>0.426471</td>\n",
       "      <td>0.050667</td>\n",
       "      <td>0.971615</td>\n",
       "      <td>0.063432</td>\n",
       "      <td>0.059166</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(584.0, inf]</td>\n",
       "      <td>293</td>\n",
       "      <td>172</td>\n",
       "      <td>465</td>\n",
       "      <td>0.226277</td>\n",
       "      <td>0.369892</td>\n",
       "      <td>0.285867</td>\n",
       "      <td>0.842715</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.059166</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev7_bin  def_pd1    (0.0, 541.0]        59        76    135   \n",
       "1  scorev7_bin  def_pd1  (541.0, 558.0]       138       161    299   \n",
       "2  scorev7_bin  def_pd1  (558.0, 584.0]       663       493   1156   \n",
       "3  scorev7_bin  def_pd1    (584.0, inf]       293       172    465   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.065693       0.562963 -0.491149  1.282582  0.033086  0.059166  \n",
       "1    0.145499       0.538462 -0.396925  1.226761  0.091891  0.059166  \n",
       "2    0.562530       0.426471  0.050667  0.971615  0.063432  0.059166  \n",
       "3    0.226277       0.369892  0.285867  0.842715  0.000000  0.059166  "
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AL')&(df['device_type']=='android')&(df['new_old_user_status']==0)&(df['scorev7']>0) \n",
    "df['scorev7_bin'] = pd.cut(df['scorev7'],[0,541,558,584,np.inf])\n",
    "kit.univerate(df[condition],'scorev7_bin','def_pd1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "ce6e5e52a196fa30",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:46:25.778421Z",
     "start_time": "2024-03-20T06:46:25.741751Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_27965/1208034288.py:63: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.\n",
      "  grouped = data.groupby(group)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>repayment_week</th>\n",
       "      <th>scorev7_bin</th>\n",
       "      <th>def_pd1</th>\n",
       "      <th>agr_pd1</th>\n",
       "      <th>def_cpd</th>\n",
       "      <th>agr_cpd</th>\n",
       "      <th>pd1</th>\n",
       "      <th>cpd</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(0.0, 541.0]</td>\n",
       "      <td>25</td>\n",
       "      <td>41</td>\n",
       "      <td>24</td>\n",
       "      <td>41</td>\n",
       "      <td>0.609756</td>\n",
       "      <td>0.585366</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(541.0, 558.0]</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>8</td>\n",
       "      <td>30</td>\n",
       "      <td>0.366667</td>\n",
       "      <td>0.266667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(558.0, 584.0]</td>\n",
       "      <td>27</td>\n",
       "      <td>79</td>\n",
       "      <td>23</td>\n",
       "      <td>79</td>\n",
       "      <td>0.341772</td>\n",
       "      <td>0.291139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(584.0, inf]</td>\n",
       "      <td>10</td>\n",
       "      <td>37</td>\n",
       "      <td>9</td>\n",
       "      <td>37</td>\n",
       "      <td>0.270270</td>\n",
       "      <td>0.243243</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(0.0, 541.0]</td>\n",
       "      <td>39</td>\n",
       "      <td>71</td>\n",
       "      <td>36</td>\n",
       "      <td>71</td>\n",
       "      <td>0.549296</td>\n",
       "      <td>0.507042</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(541.0, 558.0]</td>\n",
       "      <td>25</td>\n",
       "      <td>52</td>\n",
       "      <td>22</td>\n",
       "      <td>52</td>\n",
       "      <td>0.480769</td>\n",
       "      <td>0.423077</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(558.0, 584.0]</td>\n",
       "      <td>58</td>\n",
       "      <td>174</td>\n",
       "      <td>52</td>\n",
       "      <td>174</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.298851</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(584.0, inf]</td>\n",
       "      <td>23</td>\n",
       "      <td>65</td>\n",
       "      <td>19</td>\n",
       "      <td>65</td>\n",
       "      <td>0.353846</td>\n",
       "      <td>0.292308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(0.0, 541.0]</td>\n",
       "      <td>6</td>\n",
       "      <td>11</td>\n",
       "      <td>6</td>\n",
       "      <td>11</td>\n",
       "      <td>0.545455</td>\n",
       "      <td>0.545455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(541.0, 558.0]</td>\n",
       "      <td>17</td>\n",
       "      <td>43</td>\n",
       "      <td>16</td>\n",
       "      <td>43</td>\n",
       "      <td>0.395349</td>\n",
       "      <td>0.372093</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(558.0, 584.0]</td>\n",
       "      <td>43</td>\n",
       "      <td>107</td>\n",
       "      <td>33</td>\n",
       "      <td>107</td>\n",
       "      <td>0.401869</td>\n",
       "      <td>0.308411</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(584.0, inf]</td>\n",
       "      <td>10</td>\n",
       "      <td>33</td>\n",
       "      <td>9</td>\n",
       "      <td>33</td>\n",
       "      <td>0.303030</td>\n",
       "      <td>0.272727</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(0.0, 541.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(541.0, 558.0]</td>\n",
       "      <td>27</td>\n",
       "      <td>35</td>\n",
       "      <td>24</td>\n",
       "      <td>35</td>\n",
       "      <td>0.771429</td>\n",
       "      <td>0.685714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(558.0, 584.0]</td>\n",
       "      <td>49</td>\n",
       "      <td>97</td>\n",
       "      <td>37</td>\n",
       "      <td>97</td>\n",
       "      <td>0.505155</td>\n",
       "      <td>0.381443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(584.0, inf]</td>\n",
       "      <td>18</td>\n",
       "      <td>35</td>\n",
       "      <td>16</td>\n",
       "      <td>35</td>\n",
       "      <td>0.514286</td>\n",
       "      <td>0.457143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(0.0, 541.0]</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(541.0, 558.0]</td>\n",
       "      <td>13</td>\n",
       "      <td>20</td>\n",
       "      <td>12</td>\n",
       "      <td>20</td>\n",
       "      <td>0.650000</td>\n",
       "      <td>0.600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(558.0, 584.0]</td>\n",
       "      <td>44</td>\n",
       "      <td>102</td>\n",
       "      <td>38</td>\n",
       "      <td>102</td>\n",
       "      <td>0.431373</td>\n",
       "      <td>0.372549</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(584.0, inf]</td>\n",
       "      <td>12</td>\n",
       "      <td>31</td>\n",
       "      <td>12</td>\n",
       "      <td>31</td>\n",
       "      <td>0.387097</td>\n",
       "      <td>0.387097</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(0.0, 541.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(541.0, 558.0]</td>\n",
       "      <td>19</td>\n",
       "      <td>28</td>\n",
       "      <td>17</td>\n",
       "      <td>28</td>\n",
       "      <td>0.678571</td>\n",
       "      <td>0.607143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(558.0, 584.0]</td>\n",
       "      <td>52</td>\n",
       "      <td>117</td>\n",
       "      <td>42</td>\n",
       "      <td>117</td>\n",
       "      <td>0.444444</td>\n",
       "      <td>0.358974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(584.0, inf]</td>\n",
       "      <td>16</td>\n",
       "      <td>46</td>\n",
       "      <td>14</td>\n",
       "      <td>46</td>\n",
       "      <td>0.347826</td>\n",
       "      <td>0.304348</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(0.0, 541.0]</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>0.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(541.0, 558.0]</td>\n",
       "      <td>21</td>\n",
       "      <td>41</td>\n",
       "      <td>20</td>\n",
       "      <td>41</td>\n",
       "      <td>0.512195</td>\n",
       "      <td>0.487805</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(558.0, 584.0]</td>\n",
       "      <td>59</td>\n",
       "      <td>137</td>\n",
       "      <td>50</td>\n",
       "      <td>137</td>\n",
       "      <td>0.430657</td>\n",
       "      <td>0.364964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(584.0, inf]</td>\n",
       "      <td>22</td>\n",
       "      <td>60</td>\n",
       "      <td>17</td>\n",
       "      <td>60</td>\n",
       "      <td>0.366667</td>\n",
       "      <td>0.283333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(0.0, 541.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(541.0, 558.0]</td>\n",
       "      <td>3</td>\n",
       "      <td>11</td>\n",
       "      <td>2</td>\n",
       "      <td>11</td>\n",
       "      <td>0.272727</td>\n",
       "      <td>0.181818</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(558.0, 584.0]</td>\n",
       "      <td>39</td>\n",
       "      <td>98</td>\n",
       "      <td>34</td>\n",
       "      <td>98</td>\n",
       "      <td>0.397959</td>\n",
       "      <td>0.346939</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(584.0, inf]</td>\n",
       "      <td>23</td>\n",
       "      <td>55</td>\n",
       "      <td>19</td>\n",
       "      <td>55</td>\n",
       "      <td>0.418182</td>\n",
       "      <td>0.345455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(0.0, 541.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(541.0, 558.0]</td>\n",
       "      <td>16</td>\n",
       "      <td>25</td>\n",
       "      <td>14</td>\n",
       "      <td>25</td>\n",
       "      <td>0.640000</td>\n",
       "      <td>0.560000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(558.0, 584.0]</td>\n",
       "      <td>100</td>\n",
       "      <td>197</td>\n",
       "      <td>90</td>\n",
       "      <td>197</td>\n",
       "      <td>0.507614</td>\n",
       "      <td>0.456853</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(584.0, inf]</td>\n",
       "      <td>30</td>\n",
       "      <td>77</td>\n",
       "      <td>28</td>\n",
       "      <td>77</td>\n",
       "      <td>0.389610</td>\n",
       "      <td>0.363636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(0.0, 541.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(541.0, 558.0]</td>\n",
       "      <td>9</td>\n",
       "      <td>14</td>\n",
       "      <td>9</td>\n",
       "      <td>14</td>\n",
       "      <td>0.642857</td>\n",
       "      <td>0.642857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(558.0, 584.0]</td>\n",
       "      <td>22</td>\n",
       "      <td>48</td>\n",
       "      <td>22</td>\n",
       "      <td>48</td>\n",
       "      <td>0.458333</td>\n",
       "      <td>0.458333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(584.0, inf]</td>\n",
       "      <td>8</td>\n",
       "      <td>26</td>\n",
       "      <td>7</td>\n",
       "      <td>26</td>\n",
       "      <td>0.307692</td>\n",
       "      <td>0.269231</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      repayment_week     scorev7_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n",
       "0   2024.01.15~01.21    (0.0, 541.0]       25       41       24       41   \n",
       "1   2024.01.15~01.21  (541.0, 558.0]       11       30        8       30   \n",
       "2   2024.01.15~01.21  (558.0, 584.0]       27       79       23       79   \n",
       "3   2024.01.15~01.21    (584.0, inf]       10       37        9       37   \n",
       "4   2024.01.22~01.28    (0.0, 541.0]       39       71       36       71   \n",
       "5   2024.01.22~01.28  (541.0, 558.0]       25       52       22       52   \n",
       "6   2024.01.22~01.28  (558.0, 584.0]       58      174       52      174   \n",
       "7   2024.01.22~01.28    (584.0, inf]       23       65       19       65   \n",
       "8   2024.01.29~02.04    (0.0, 541.0]        6       11        6       11   \n",
       "9   2024.01.29~02.04  (541.0, 558.0]       17       43       16       43   \n",
       "10  2024.01.29~02.04  (558.0, 584.0]       43      107       33      107   \n",
       "11  2024.01.29~02.04    (584.0, inf]       10       33        9       33   \n",
       "12  2024.02.05~02.11    (0.0, 541.0]        0        1        0        1   \n",
       "13  2024.02.05~02.11  (541.0, 558.0]       27       35       24       35   \n",
       "14  2024.02.05~02.11  (558.0, 584.0]       49       97       37       97   \n",
       "15  2024.02.05~02.11    (584.0, inf]       18       35       16       35   \n",
       "16  2024.02.12~02.18    (0.0, 541.0]        3        3        3        3   \n",
       "17  2024.02.12~02.18  (541.0, 558.0]       13       20       12       20   \n",
       "18  2024.02.12~02.18  (558.0, 584.0]       44      102       38      102   \n",
       "19  2024.02.12~02.18    (584.0, inf]       12       31       12       31   \n",
       "20  2024.02.19~02.25    (0.0, 541.0]        2        4        2        4   \n",
       "21  2024.02.19~02.25  (541.0, 558.0]       19       28       17       28   \n",
       "22  2024.02.19~02.25  (558.0, 584.0]       52      117       42      117   \n",
       "23  2024.02.19~02.25    (584.0, inf]       16       46       14       46   \n",
       "24  2024.02.26~03.03    (0.0, 541.0]        1        4        1        4   \n",
       "25  2024.02.26~03.03  (541.0, 558.0]       21       41       20       41   \n",
       "26  2024.02.26~03.03  (558.0, 584.0]       59      137       50      137   \n",
       "27  2024.02.26~03.03    (584.0, inf]       22       60       17       60   \n",
       "28  2024.03.04~03.10    (0.0, 541.0]        0        0        0        0   \n",
       "29  2024.03.04~03.10  (541.0, 558.0]        3       11        2       11   \n",
       "30  2024.03.04~03.10  (558.0, 584.0]       39       98       34       98   \n",
       "31  2024.03.04~03.10    (584.0, inf]       23       55       19       55   \n",
       "32  2024.03.11~03.17    (0.0, 541.0]        0        0        0        0   \n",
       "33  2024.03.11~03.17  (541.0, 558.0]       16       25       14       25   \n",
       "34  2024.03.11~03.17  (558.0, 584.0]      100      197       90      197   \n",
       "35  2024.03.11~03.17    (584.0, inf]       30       77       28       77   \n",
       "36  2024.03.18~03.24    (0.0, 541.0]        0        0        0        0   \n",
       "37  2024.03.18~03.24  (541.0, 558.0]        9       14        9       14   \n",
       "38  2024.03.18~03.24  (558.0, 584.0]       22       48       22       48   \n",
       "39  2024.03.18~03.24    (584.0, inf]        8       26        7       26   \n",
       "\n",
       "         pd1       cpd  \n",
       "0   0.609756  0.585366  \n",
       "1   0.366667  0.266667  \n",
       "2   0.341772  0.291139  \n",
       "3   0.270270  0.243243  \n",
       "4   0.549296  0.507042  \n",
       "5   0.480769  0.423077  \n",
       "6   0.333333  0.298851  \n",
       "7   0.353846  0.292308  \n",
       "8   0.545455  0.545455  \n",
       "9   0.395349  0.372093  \n",
       "10  0.401869  0.308411  \n",
       "11  0.303030  0.272727  \n",
       "12  0.000000  0.000000  \n",
       "13  0.771429  0.685714  \n",
       "14  0.505155  0.381443  \n",
       "15  0.514286  0.457143  \n",
       "16  1.000000  1.000000  \n",
       "17  0.650000  0.600000  \n",
       "18  0.431373  0.372549  \n",
       "19  0.387097  0.387097  \n",
       "20  0.500000  0.500000  \n",
       "21  0.678571  0.607143  \n",
       "22  0.444444  0.358974  \n",
       "23  0.347826  0.304348  \n",
       "24  0.250000  0.250000  \n",
       "25  0.512195  0.487805  \n",
       "26  0.430657  0.364964  \n",
       "27  0.366667  0.283333  \n",
       "28       NaN       NaN  \n",
       "29  0.272727  0.181818  \n",
       "30  0.397959  0.346939  \n",
       "31  0.418182  0.345455  \n",
       "32       NaN       NaN  \n",
       "33  0.640000  0.560000  \n",
       "34  0.507614  0.456853  \n",
       "35  0.389610  0.363636  \n",
       "36       NaN       NaN  \n",
       "37  0.642857  0.642857  \n",
       "38  0.458333  0.458333  \n",
       "39  0.307692  0.269231  "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev7_bin']\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "29901b1c43c9c2cf",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-06T01:54:04.933278Z",
     "start_time": "2024-02-06T01:54:04.038182Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(0.0, 558.0]</td>\n",
       "      <td>56</td>\n",
       "      <td>106</td>\n",
       "      <td>162</td>\n",
       "      <td>0.059124</td>\n",
       "      <td>0.654321</td>\n",
       "      <td>-1.008498</td>\n",
       "      <td>1.619548</td>\n",
       "      <td>0.061462</td>\n",
       "      <td>0.073771</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(558.0, 575.0]</td>\n",
       "      <td>277</td>\n",
       "      <td>193</td>\n",
       "      <td>470</td>\n",
       "      <td>0.171533</td>\n",
       "      <td>0.410638</td>\n",
       "      <td>-0.027279</td>\n",
       "      <td>1.016395</td>\n",
       "      <td>0.066180</td>\n",
       "      <td>0.073771</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(575.0, 584.0]</td>\n",
       "      <td>761</td>\n",
       "      <td>505</td>\n",
       "      <td>1266</td>\n",
       "      <td>0.462044</td>\n",
       "      <td>0.398894</td>\n",
       "      <td>0.021264</td>\n",
       "      <td>0.987326</td>\n",
       "      <td>0.056355</td>\n",
       "      <td>0.073771</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(584.0, 588.0]</td>\n",
       "      <td>332</td>\n",
       "      <td>195</td>\n",
       "      <td>527</td>\n",
       "      <td>0.192336</td>\n",
       "      <td>0.370019</td>\n",
       "      <td>0.142616</td>\n",
       "      <td>0.915855</td>\n",
       "      <td>0.029200</td>\n",
       "      <td>0.073771</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(588.0, inf]</td>\n",
       "      <td>207</td>\n",
       "      <td>108</td>\n",
       "      <td>315</td>\n",
       "      <td>0.114964</td>\n",
       "      <td>0.342857</td>\n",
       "      <td>0.259483</td>\n",
       "      <td>0.848626</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.073771</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev7_bin  def_pd1    (0.0, 558.0]        56       106    162   \n",
       "1  scorev7_bin  def_pd1  (558.0, 575.0]       277       193    470   \n",
       "2  scorev7_bin  def_pd1  (575.0, 584.0]       761       505   1266   \n",
       "3  scorev7_bin  def_pd1  (584.0, 588.0]       332       195    527   \n",
       "4  scorev7_bin  def_pd1    (588.0, inf]       207       108    315   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.059124       0.654321 -1.008498  1.619548  0.061462  0.073771  \n",
       "1    0.171533       0.410638 -0.027279  1.016395  0.066180  0.073771  \n",
       "2    0.462044       0.398894  0.021264  0.987326  0.056355  0.073771  \n",
       "3    0.192336       0.370019  0.142616  0.915855  0.029200  0.073771  \n",
       "4    0.114964       0.342857  0.259483  0.848626  0.000000  0.073771  "
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AL')&(df['device_type']=='android')&(df['new_old_user_status']==1)&(df['scorev7']>0) \n",
    "df['scorev7_bin'] = pd.cut(df['scorev7'],[0,558,575,584,588,np.inf])\n",
    "kit.univerate(df[condition],'scorev7_bin','def_pd1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "6245a7b7",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_6508/218088919.py:63: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.\n",
      "  grouped = data.groupby(group)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>repayment_week</th>\n",
       "      <th>scorev7_bin</th>\n",
       "      <th>def_pd1</th>\n",
       "      <th>agr_pd1</th>\n",
       "      <th>def_cpd</th>\n",
       "      <th>agr_cpd</th>\n",
       "      <th>pd1</th>\n",
       "      <th>cpd</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(0.0, 558.0]</td>\n",
       "      <td>30</td>\n",
       "      <td>42</td>\n",
       "      <td>29</td>\n",
       "      <td>42</td>\n",
       "      <td>0.714286</td>\n",
       "      <td>0.690476</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(558.0, 575.0]</td>\n",
       "      <td>29</td>\n",
       "      <td>67</td>\n",
       "      <td>24</td>\n",
       "      <td>67</td>\n",
       "      <td>0.432836</td>\n",
       "      <td>0.358209</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(575.0, 584.0]</td>\n",
       "      <td>81</td>\n",
       "      <td>152</td>\n",
       "      <td>73</td>\n",
       "      <td>152</td>\n",
       "      <td>0.532895</td>\n",
       "      <td>0.480263</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(584.0, 588.0]</td>\n",
       "      <td>35</td>\n",
       "      <td>78</td>\n",
       "      <td>29</td>\n",
       "      <td>78</td>\n",
       "      <td>0.448718</td>\n",
       "      <td>0.371795</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(588.0, inf]</td>\n",
       "      <td>17</td>\n",
       "      <td>56</td>\n",
       "      <td>17</td>\n",
       "      <td>56</td>\n",
       "      <td>0.303571</td>\n",
       "      <td>0.303571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(0.0, 558.0]</td>\n",
       "      <td>69</td>\n",
       "      <td>106</td>\n",
       "      <td>63</td>\n",
       "      <td>106</td>\n",
       "      <td>0.650943</td>\n",
       "      <td>0.594340</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(558.0, 575.0]</td>\n",
       "      <td>62</td>\n",
       "      <td>121</td>\n",
       "      <td>52</td>\n",
       "      <td>121</td>\n",
       "      <td>0.512397</td>\n",
       "      <td>0.429752</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(575.0, 584.0]</td>\n",
       "      <td>99</td>\n",
       "      <td>277</td>\n",
       "      <td>82</td>\n",
       "      <td>277</td>\n",
       "      <td>0.357401</td>\n",
       "      <td>0.296029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(584.0, 588.0]</td>\n",
       "      <td>46</td>\n",
       "      <td>102</td>\n",
       "      <td>41</td>\n",
       "      <td>102</td>\n",
       "      <td>0.450980</td>\n",
       "      <td>0.401961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(588.0, inf]</td>\n",
       "      <td>41</td>\n",
       "      <td>90</td>\n",
       "      <td>32</td>\n",
       "      <td>90</td>\n",
       "      <td>0.455556</td>\n",
       "      <td>0.355556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(0.0, 558.0]</td>\n",
       "      <td>7</td>\n",
       "      <td>14</td>\n",
       "      <td>6</td>\n",
       "      <td>14</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.428571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(558.0, 575.0]</td>\n",
       "      <td>18</td>\n",
       "      <td>70</td>\n",
       "      <td>16</td>\n",
       "      <td>70</td>\n",
       "      <td>0.257143</td>\n",
       "      <td>0.228571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(575.0, 584.0]</td>\n",
       "      <td>77</td>\n",
       "      <td>226</td>\n",
       "      <td>67</td>\n",
       "      <td>226</td>\n",
       "      <td>0.340708</td>\n",
       "      <td>0.296460</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(584.0, 588.0]</td>\n",
       "      <td>45</td>\n",
       "      <td>95</td>\n",
       "      <td>42</td>\n",
       "      <td>95</td>\n",
       "      <td>0.473684</td>\n",
       "      <td>0.442105</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(588.0, inf]</td>\n",
       "      <td>18</td>\n",
       "      <td>53</td>\n",
       "      <td>16</td>\n",
       "      <td>53</td>\n",
       "      <td>0.339623</td>\n",
       "      <td>0.301887</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(0.0, 558.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(558.0, 575.0]</td>\n",
       "      <td>34</td>\n",
       "      <td>88</td>\n",
       "      <td>24</td>\n",
       "      <td>88</td>\n",
       "      <td>0.386364</td>\n",
       "      <td>0.272727</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(575.0, 584.0]</td>\n",
       "      <td>96</td>\n",
       "      <td>259</td>\n",
       "      <td>81</td>\n",
       "      <td>259</td>\n",
       "      <td>0.370656</td>\n",
       "      <td>0.312741</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(584.0, 588.0]</td>\n",
       "      <td>26</td>\n",
       "      <td>117</td>\n",
       "      <td>19</td>\n",
       "      <td>117</td>\n",
       "      <td>0.222222</td>\n",
       "      <td>0.162393</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(588.0, inf]</td>\n",
       "      <td>11</td>\n",
       "      <td>48</td>\n",
       "      <td>10</td>\n",
       "      <td>48</td>\n",
       "      <td>0.229167</td>\n",
       "      <td>0.208333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(0.0, 558.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(558.0, 575.0]</td>\n",
       "      <td>39</td>\n",
       "      <td>94</td>\n",
       "      <td>31</td>\n",
       "      <td>94</td>\n",
       "      <td>0.414894</td>\n",
       "      <td>0.329787</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(575.0, 584.0]</td>\n",
       "      <td>117</td>\n",
       "      <td>261</td>\n",
       "      <td>76</td>\n",
       "      <td>261</td>\n",
       "      <td>0.448276</td>\n",
       "      <td>0.291188</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(584.0, 588.0]</td>\n",
       "      <td>29</td>\n",
       "      <td>102</td>\n",
       "      <td>21</td>\n",
       "      <td>102</td>\n",
       "      <td>0.284314</td>\n",
       "      <td>0.205882</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(588.0, inf]</td>\n",
       "      <td>13</td>\n",
       "      <td>42</td>\n",
       "      <td>7</td>\n",
       "      <td>42</td>\n",
       "      <td>0.309524</td>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(0.0, 558.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(558.0, 575.0]</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>9</td>\n",
       "      <td>30</td>\n",
       "      <td>0.366667</td>\n",
       "      <td>0.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(575.0, 584.0]</td>\n",
       "      <td>35</td>\n",
       "      <td>91</td>\n",
       "      <td>30</td>\n",
       "      <td>91</td>\n",
       "      <td>0.384615</td>\n",
       "      <td>0.329670</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(584.0, 588.0]</td>\n",
       "      <td>14</td>\n",
       "      <td>33</td>\n",
       "      <td>12</td>\n",
       "      <td>33</td>\n",
       "      <td>0.424242</td>\n",
       "      <td>0.363636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(588.0, inf]</td>\n",
       "      <td>8</td>\n",
       "      <td>26</td>\n",
       "      <td>7</td>\n",
       "      <td>26</td>\n",
       "      <td>0.307692</td>\n",
       "      <td>0.269231</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      repayment_week     scorev7_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n",
       "0   2024.01.15~01.21    (0.0, 558.0]       30       42       29       42   \n",
       "1   2024.01.15~01.21  (558.0, 575.0]       29       67       24       67   \n",
       "2   2024.01.15~01.21  (575.0, 584.0]       81      152       73      152   \n",
       "3   2024.01.15~01.21  (584.0, 588.0]       35       78       29       78   \n",
       "4   2024.01.15~01.21    (588.0, inf]       17       56       17       56   \n",
       "5   2024.01.22~01.28    (0.0, 558.0]       69      106       63      106   \n",
       "6   2024.01.22~01.28  (558.0, 575.0]       62      121       52      121   \n",
       "7   2024.01.22~01.28  (575.0, 584.0]       99      277       82      277   \n",
       "8   2024.01.22~01.28  (584.0, 588.0]       46      102       41      102   \n",
       "9   2024.01.22~01.28    (588.0, inf]       41       90       32       90   \n",
       "10  2024.01.29~02.04    (0.0, 558.0]        7       14        6       14   \n",
       "11  2024.01.29~02.04  (558.0, 575.0]       18       70       16       70   \n",
       "12  2024.01.29~02.04  (575.0, 584.0]       77      226       67      226   \n",
       "13  2024.01.29~02.04  (584.0, 588.0]       45       95       42       95   \n",
       "14  2024.01.29~02.04    (588.0, inf]       18       53       16       53   \n",
       "15  2024.02.05~02.11    (0.0, 558.0]        0        0        0        0   \n",
       "16  2024.02.05~02.11  (558.0, 575.0]       34       88       24       88   \n",
       "17  2024.02.05~02.11  (575.0, 584.0]       96      259       81      259   \n",
       "18  2024.02.05~02.11  (584.0, 588.0]       26      117       19      117   \n",
       "19  2024.02.05~02.11    (588.0, inf]       11       48       10       48   \n",
       "20  2024.02.12~02.18    (0.0, 558.0]        0        0        0        0   \n",
       "21  2024.02.12~02.18  (558.0, 575.0]       39       94       31       94   \n",
       "22  2024.02.12~02.18  (575.0, 584.0]      117      261       76      261   \n",
       "23  2024.02.12~02.18  (584.0, 588.0]       29      102       21      102   \n",
       "24  2024.02.12~02.18    (588.0, inf]       13       42        7       42   \n",
       "25  2024.02.19~02.25    (0.0, 558.0]        0        0        0        0   \n",
       "26  2024.02.19~02.25  (558.0, 575.0]       11       30        9       30   \n",
       "27  2024.02.19~02.25  (575.0, 584.0]       35       91       30       91   \n",
       "28  2024.02.19~02.25  (584.0, 588.0]       14       33       12       33   \n",
       "29  2024.02.19~02.25    (588.0, inf]        8       26        7       26   \n",
       "\n",
       "         pd1       cpd  \n",
       "0   0.714286  0.690476  \n",
       "1   0.432836  0.358209  \n",
       "2   0.532895  0.480263  \n",
       "3   0.448718  0.371795  \n",
       "4   0.303571  0.303571  \n",
       "5   0.650943  0.594340  \n",
       "6   0.512397  0.429752  \n",
       "7   0.357401  0.296029  \n",
       "8   0.450980  0.401961  \n",
       "9   0.455556  0.355556  \n",
       "10  0.500000  0.428571  \n",
       "11  0.257143  0.228571  \n",
       "12  0.340708  0.296460  \n",
       "13  0.473684  0.442105  \n",
       "14  0.339623  0.301887  \n",
       "15       NaN       NaN  \n",
       "16  0.386364  0.272727  \n",
       "17  0.370656  0.312741  \n",
       "18  0.222222  0.162393  \n",
       "19  0.229167  0.208333  \n",
       "20       NaN       NaN  \n",
       "21  0.414894  0.329787  \n",
       "22  0.448276  0.291188  \n",
       "23  0.284314  0.205882  \n",
       "24  0.309524  0.166667  \n",
       "25       NaN       NaN  \n",
       "26  0.366667  0.300000  \n",
       "27  0.384615  0.329670  \n",
       "28  0.424242  0.363636  \n",
       "29  0.307692  0.269231  "
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev7_bin']\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "29a0d3856baa03e2",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-06T01:54:04.935138Z",
     "start_time": "2024-02-06T01:54:04.250591Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(0.0, 558.0]</td>\n",
       "      <td>64</td>\n",
       "      <td>90</td>\n",
       "      <td>154</td>\n",
       "      <td>0.080167</td>\n",
       "      <td>0.584416</td>\n",
       "      <td>-0.581530</td>\n",
       "      <td>1.333328</td>\n",
       "      <td>0.047574</td>\n",
       "      <td>0.036244</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(558.0, 575.0]</td>\n",
       "      <td>214</td>\n",
       "      <td>163</td>\n",
       "      <td>377</td>\n",
       "      <td>0.196252</td>\n",
       "      <td>0.432361</td>\n",
       "      <td>0.024093</td>\n",
       "      <td>0.986419</td>\n",
       "      <td>0.042829</td>\n",
       "      <td>0.036244</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(575.0, 584.0]</td>\n",
       "      <td>499</td>\n",
       "      <td>358</td>\n",
       "      <td>857</td>\n",
       "      <td>0.446122</td>\n",
       "      <td>0.417736</td>\n",
       "      <td>0.083874</td>\n",
       "      <td>0.953054</td>\n",
       "      <td>0.005542</td>\n",
       "      <td>0.036244</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(584.0, 588.0]</td>\n",
       "      <td>184</td>\n",
       "      <td>156</td>\n",
       "      <td>340</td>\n",
       "      <td>0.176991</td>\n",
       "      <td>0.458824</td>\n",
       "      <td>-0.082466</td>\n",
       "      <td>1.046793</td>\n",
       "      <td>0.020287</td>\n",
       "      <td>0.036244</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>scorev7_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(588.0, 600.0]</td>\n",
       "      <td>118</td>\n",
       "      <td>75</td>\n",
       "      <td>193</td>\n",
       "      <td>0.100469</td>\n",
       "      <td>0.388601</td>\n",
       "      <td>0.203125</td>\n",
       "      <td>0.886583</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.036244</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev7_bin  def_pd1    (0.0, 558.0]        64        90    154   \n",
       "1  scorev7_bin  def_pd1  (558.0, 575.0]       214       163    377   \n",
       "2  scorev7_bin  def_pd1  (575.0, 584.0]       499       358    857   \n",
       "3  scorev7_bin  def_pd1  (584.0, 588.0]       184       156    340   \n",
       "4  scorev7_bin  def_pd1  (588.0, 600.0]       118        75    193   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.080167       0.584416 -0.581530  1.333328  0.047574  0.036244  \n",
       "1    0.196252       0.432361  0.024093  0.986419  0.042829  0.036244  \n",
       "2    0.446122       0.417736  0.083874  0.953054  0.005542  0.036244  \n",
       "3    0.176991       0.458824 -0.082466  1.046793  0.020287  0.036244  \n",
       "4    0.100469       0.388601  0.203125  0.886583  0.000000  0.036244  "
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AL')&(df['device_type']=='android')&(df['new_old_user_status']==2)&(df['scorev7']>0) \n",
    "df['scorev7_bin'] = pd.cut(df['scorev7'],[0,558,575,584,588,600,np.inf])\n",
    "kit.univerate(df[condition],'scorev7_bin','def_pd1')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7df7166f",
   "metadata": {},
   "source": [
    "# scorev8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "6aebdc9b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:47:12.540696Z",
     "start_time": "2024-03-20T06:47:12.418895Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev8_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(0.0, 521.0]</td>\n",
       "      <td>130</td>\n",
       "      <td>152</td>\n",
       "      <td>282</td>\n",
       "      <td>0.040006</td>\n",
       "      <td>0.539007</td>\n",
       "      <td>-0.350549</td>\n",
       "      <td>1.199325</td>\n",
       "      <td>0.014483</td>\n",
       "      <td>0.03072</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev8_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>331</td>\n",
       "      <td>352</td>\n",
       "      <td>683</td>\n",
       "      <td>0.096893</td>\n",
       "      <td>0.515373</td>\n",
       "      <td>-0.261808</td>\n",
       "      <td>1.146738</td>\n",
       "      <td>0.040307</td>\n",
       "      <td>0.03072</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev8_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(542.0, 576.0]</td>\n",
       "      <td>1295</td>\n",
       "      <td>1108</td>\n",
       "      <td>2403</td>\n",
       "      <td>0.340899</td>\n",
       "      <td>0.461090</td>\n",
       "      <td>-0.046901</td>\n",
       "      <td>1.025955</td>\n",
       "      <td>0.056378</td>\n",
       "      <td>0.03072</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev8_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(576.0, 604.0]</td>\n",
       "      <td>1553</td>\n",
       "      <td>1238</td>\n",
       "      <td>2791</td>\n",
       "      <td>0.395943</td>\n",
       "      <td>0.443569</td>\n",
       "      <td>0.023639</td>\n",
       "      <td>0.986968</td>\n",
       "      <td>0.047006</td>\n",
       "      <td>0.03072</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>scorev8_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>572</td>\n",
       "      <td>318</td>\n",
       "      <td>890</td>\n",
       "      <td>0.126259</td>\n",
       "      <td>0.357303</td>\n",
       "      <td>0.380944</td>\n",
       "      <td>0.795023</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.03072</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev8_bin  def_pd1    (0.0, 521.0]       130       152    282   \n",
       "1  scorev8_bin  def_pd1  (521.0, 542.0]       331       352    683   \n",
       "2  scorev8_bin  def_pd1  (542.0, 576.0]      1295      1108   2403   \n",
       "3  scorev8_bin  def_pd1  (576.0, 604.0]      1553      1238   2791   \n",
       "4  scorev8_bin  def_pd1    (604.0, inf]       572       318    890   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS       IV  \n",
       "0    0.040006       0.539007 -0.350549  1.199325  0.014483  0.03072  \n",
       "1    0.096893       0.515373 -0.261808  1.146738  0.040307  0.03072  \n",
       "2    0.340899       0.461090 -0.046901  1.025955  0.056378  0.03072  \n",
       "3    0.395943       0.443569  0.023639  0.986968  0.047006  0.03072  \n",
       "4    0.126259       0.357303  0.380944  0.795023  0.000000  0.03072  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']==0)&(df['scorev8']>0) #& (df['acq_channel']=='ANDF')\n",
    "df['scorev8_bin'] = pd.cut(df['scorev8'],[0,521,542,576,604,np.inf])\n",
    "kit.univerate(df[condition],'scorev8_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "b909a463",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:47:58.732227Z",
     "start_time": "2024-03-20T06:47:58.676899Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_27965/1208034288.py:63: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.\n",
      "  grouped = data.groupby(group)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>repayment_week</th>\n",
       "      <th>scorev8_bin</th>\n",
       "      <th>def_pd1</th>\n",
       "      <th>agr_pd1</th>\n",
       "      <th>def_cpd</th>\n",
       "      <th>agr_cpd</th>\n",
       "      <th>pd1</th>\n",
       "      <th>cpd</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(0.0, 521.0]</td>\n",
       "      <td>38</td>\n",
       "      <td>63</td>\n",
       "      <td>35</td>\n",
       "      <td>63</td>\n",
       "      <td>0.603175</td>\n",
       "      <td>0.555556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>84</td>\n",
       "      <td>142</td>\n",
       "      <td>78</td>\n",
       "      <td>142</td>\n",
       "      <td>0.591549</td>\n",
       "      <td>0.549296</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(542.0, 576.0]</td>\n",
       "      <td>171</td>\n",
       "      <td>388</td>\n",
       "      <td>161</td>\n",
       "      <td>388</td>\n",
       "      <td>0.440722</td>\n",
       "      <td>0.414948</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(576.0, 604.0]</td>\n",
       "      <td>96</td>\n",
       "      <td>281</td>\n",
       "      <td>87</td>\n",
       "      <td>281</td>\n",
       "      <td>0.341637</td>\n",
       "      <td>0.309609</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>21</td>\n",
       "      <td>68</td>\n",
       "      <td>20</td>\n",
       "      <td>68</td>\n",
       "      <td>0.308824</td>\n",
       "      <td>0.294118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(0.0, 521.0]</td>\n",
       "      <td>72</td>\n",
       "      <td>120</td>\n",
       "      <td>65</td>\n",
       "      <td>120</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.541667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>120</td>\n",
       "      <td>244</td>\n",
       "      <td>118</td>\n",
       "      <td>244</td>\n",
       "      <td>0.491803</td>\n",
       "      <td>0.483607</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(542.0, 576.0]</td>\n",
       "      <td>301</td>\n",
       "      <td>682</td>\n",
       "      <td>284</td>\n",
       "      <td>682</td>\n",
       "      <td>0.441349</td>\n",
       "      <td>0.416422</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(576.0, 604.0]</td>\n",
       "      <td>168</td>\n",
       "      <td>425</td>\n",
       "      <td>158</td>\n",
       "      <td>425</td>\n",
       "      <td>0.395294</td>\n",
       "      <td>0.371765</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>49</td>\n",
       "      <td>137</td>\n",
       "      <td>46</td>\n",
       "      <td>137</td>\n",
       "      <td>0.357664</td>\n",
       "      <td>0.335766</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(0.0, 521.0]</td>\n",
       "      <td>4</td>\n",
       "      <td>11</td>\n",
       "      <td>4</td>\n",
       "      <td>11</td>\n",
       "      <td>0.363636</td>\n",
       "      <td>0.363636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>17</td>\n",
       "      <td>34</td>\n",
       "      <td>17</td>\n",
       "      <td>34</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(542.0, 576.0]</td>\n",
       "      <td>101</td>\n",
       "      <td>206</td>\n",
       "      <td>92</td>\n",
       "      <td>206</td>\n",
       "      <td>0.490291</td>\n",
       "      <td>0.446602</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(576.0, 604.0]</td>\n",
       "      <td>160</td>\n",
       "      <td>366</td>\n",
       "      <td>145</td>\n",
       "      <td>366</td>\n",
       "      <td>0.437158</td>\n",
       "      <td>0.396175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>40</td>\n",
       "      <td>104</td>\n",
       "      <td>36</td>\n",
       "      <td>104</td>\n",
       "      <td>0.384615</td>\n",
       "      <td>0.346154</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(0.0, 521.0]</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(542.0, 576.0]</td>\n",
       "      <td>3</td>\n",
       "      <td>10</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "      <td>0.300000</td>\n",
       "      <td>0.200000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(576.0, 604.0]</td>\n",
       "      <td>172</td>\n",
       "      <td>367</td>\n",
       "      <td>157</td>\n",
       "      <td>367</td>\n",
       "      <td>0.468665</td>\n",
       "      <td>0.427793</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>46</td>\n",
       "      <td>118</td>\n",
       "      <td>40</td>\n",
       "      <td>118</td>\n",
       "      <td>0.389831</td>\n",
       "      <td>0.338983</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(0.0, 521.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(542.0, 576.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(576.0, 604.0]</td>\n",
       "      <td>179</td>\n",
       "      <td>352</td>\n",
       "      <td>165</td>\n",
       "      <td>352</td>\n",
       "      <td>0.508523</td>\n",
       "      <td>0.468750</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>35</td>\n",
       "      <td>102</td>\n",
       "      <td>29</td>\n",
       "      <td>102</td>\n",
       "      <td>0.343137</td>\n",
       "      <td>0.284314</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(0.0, 521.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(542.0, 576.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(576.0, 604.0]</td>\n",
       "      <td>166</td>\n",
       "      <td>339</td>\n",
       "      <td>156</td>\n",
       "      <td>339</td>\n",
       "      <td>0.489676</td>\n",
       "      <td>0.460177</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>53</td>\n",
       "      <td>116</td>\n",
       "      <td>47</td>\n",
       "      <td>116</td>\n",
       "      <td>0.456897</td>\n",
       "      <td>0.405172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(0.0, 521.0]</td>\n",
       "      <td>25</td>\n",
       "      <td>55</td>\n",
       "      <td>24</td>\n",
       "      <td>55</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>0.436364</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>95</td>\n",
       "      <td>184</td>\n",
       "      <td>92</td>\n",
       "      <td>184</td>\n",
       "      <td>0.516304</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(542.0, 576.0]</td>\n",
       "      <td>233</td>\n",
       "      <td>516</td>\n",
       "      <td>218</td>\n",
       "      <td>516</td>\n",
       "      <td>0.451550</td>\n",
       "      <td>0.422481</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(576.0, 604.0]</td>\n",
       "      <td>152</td>\n",
       "      <td>310</td>\n",
       "      <td>137</td>\n",
       "      <td>310</td>\n",
       "      <td>0.490323</td>\n",
       "      <td>0.441935</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>31</td>\n",
       "      <td>96</td>\n",
       "      <td>29</td>\n",
       "      <td>96</td>\n",
       "      <td>0.322917</td>\n",
       "      <td>0.302083</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(0.0, 521.0]</td>\n",
       "      <td>9</td>\n",
       "      <td>22</td>\n",
       "      <td>8</td>\n",
       "      <td>22</td>\n",
       "      <td>0.409091</td>\n",
       "      <td>0.363636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>16</td>\n",
       "      <td>46</td>\n",
       "      <td>16</td>\n",
       "      <td>46</td>\n",
       "      <td>0.347826</td>\n",
       "      <td>0.347826</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(542.0, 576.0]</td>\n",
       "      <td>88</td>\n",
       "      <td>166</td>\n",
       "      <td>83</td>\n",
       "      <td>166</td>\n",
       "      <td>0.530120</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(576.0, 604.0]</td>\n",
       "      <td>74</td>\n",
       "      <td>157</td>\n",
       "      <td>70</td>\n",
       "      <td>157</td>\n",
       "      <td>0.471338</td>\n",
       "      <td>0.445860</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>18</td>\n",
       "      <td>60</td>\n",
       "      <td>18</td>\n",
       "      <td>60</td>\n",
       "      <td>0.300000</td>\n",
       "      <td>0.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(0.0, 521.0]</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "      <td>0.375000</td>\n",
       "      <td>0.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>18</td>\n",
       "      <td>30</td>\n",
       "      <td>17</td>\n",
       "      <td>30</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.566667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(542.0, 576.0]</td>\n",
       "      <td>163</td>\n",
       "      <td>327</td>\n",
       "      <td>157</td>\n",
       "      <td>327</td>\n",
       "      <td>0.498471</td>\n",
       "      <td>0.480122</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(576.0, 604.0]</td>\n",
       "      <td>64</td>\n",
       "      <td>155</td>\n",
       "      <td>59</td>\n",
       "      <td>155</td>\n",
       "      <td>0.412903</td>\n",
       "      <td>0.380645</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>16</td>\n",
       "      <td>73</td>\n",
       "      <td>16</td>\n",
       "      <td>73</td>\n",
       "      <td>0.219178</td>\n",
       "      <td>0.219178</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(0.0, 521.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.666667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(542.0, 576.0]</td>\n",
       "      <td>48</td>\n",
       "      <td>103</td>\n",
       "      <td>47</td>\n",
       "      <td>103</td>\n",
       "      <td>0.466019</td>\n",
       "      <td>0.456311</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(576.0, 604.0]</td>\n",
       "      <td>7</td>\n",
       "      <td>39</td>\n",
       "      <td>7</td>\n",
       "      <td>39</td>\n",
       "      <td>0.179487</td>\n",
       "      <td>0.179487</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>9</td>\n",
       "      <td>16</td>\n",
       "      <td>9</td>\n",
       "      <td>16</td>\n",
       "      <td>0.562500</td>\n",
       "      <td>0.562500</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      repayment_week     scorev8_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n",
       "0   2024.01.15~01.21    (0.0, 521.0]       38       63       35       63   \n",
       "1   2024.01.15~01.21  (521.0, 542.0]       84      142       78      142   \n",
       "2   2024.01.15~01.21  (542.0, 576.0]      171      388      161      388   \n",
       "3   2024.01.15~01.21  (576.0, 604.0]       96      281       87      281   \n",
       "4   2024.01.15~01.21    (604.0, inf]       21       68       20       68   \n",
       "5   2024.01.22~01.28    (0.0, 521.0]       72      120       65      120   \n",
       "6   2024.01.22~01.28  (521.0, 542.0]      120      244      118      244   \n",
       "7   2024.01.22~01.28  (542.0, 576.0]      301      682      284      682   \n",
       "8   2024.01.22~01.28  (576.0, 604.0]      168      425      158      425   \n",
       "9   2024.01.22~01.28    (604.0, inf]       49      137       46      137   \n",
       "10  2024.01.29~02.04    (0.0, 521.0]        4       11        4       11   \n",
       "11  2024.01.29~02.04  (521.0, 542.0]       17       34       17       34   \n",
       "12  2024.01.29~02.04  (542.0, 576.0]      101      206       92      206   \n",
       "13  2024.01.29~02.04  (576.0, 604.0]      160      366      145      366   \n",
       "14  2024.01.29~02.04    (604.0, inf]       40      104       36      104   \n",
       "15  2024.02.05~02.11    (0.0, 521.0]        1        1        1        1   \n",
       "16  2024.02.05~02.11  (521.0, 542.0]        0        0        0        0   \n",
       "17  2024.02.05~02.11  (542.0, 576.0]        3       10        2       10   \n",
       "18  2024.02.05~02.11  (576.0, 604.0]      172      367      157      367   \n",
       "19  2024.02.05~02.11    (604.0, inf]       46      118       40      118   \n",
       "20  2024.02.12~02.18    (0.0, 521.0]        0        0        0        0   \n",
       "21  2024.02.12~02.18  (521.0, 542.0]        0        0        0        0   \n",
       "22  2024.02.12~02.18  (542.0, 576.0]        0        2        0        2   \n",
       "23  2024.02.12~02.18  (576.0, 604.0]      179      352      165      352   \n",
       "24  2024.02.12~02.18    (604.0, inf]       35      102       29      102   \n",
       "25  2024.02.19~02.25    (0.0, 521.0]        0        0        0        0   \n",
       "26  2024.02.19~02.25  (521.0, 542.0]        0        0        0        0   \n",
       "27  2024.02.19~02.25  (542.0, 576.0]        0        3        0        3   \n",
       "28  2024.02.19~02.25  (576.0, 604.0]      166      339      156      339   \n",
       "29  2024.02.19~02.25    (604.0, inf]       53      116       47      116   \n",
       "30  2024.02.26~03.03    (0.0, 521.0]       25       55       24       55   \n",
       "31  2024.02.26~03.03  (521.0, 542.0]       95      184       92      184   \n",
       "32  2024.02.26~03.03  (542.0, 576.0]      233      516      218      516   \n",
       "33  2024.02.26~03.03  (576.0, 604.0]      152      310      137      310   \n",
       "34  2024.02.26~03.03    (604.0, inf]       31       96       29       96   \n",
       "35  2024.03.04~03.10    (0.0, 521.0]        9       22        8       22   \n",
       "36  2024.03.04~03.10  (521.0, 542.0]       16       46       16       46   \n",
       "37  2024.03.04~03.10  (542.0, 576.0]       88      166       83      166   \n",
       "38  2024.03.04~03.10  (576.0, 604.0]       74      157       70      157   \n",
       "39  2024.03.04~03.10    (604.0, inf]       18       60       18       60   \n",
       "40  2024.03.11~03.17    (0.0, 521.0]        3        8        2        8   \n",
       "41  2024.03.11~03.17  (521.0, 542.0]       18       30       17       30   \n",
       "42  2024.03.11~03.17  (542.0, 576.0]      163      327      157      327   \n",
       "43  2024.03.11~03.17  (576.0, 604.0]       64      155       59      155   \n",
       "44  2024.03.11~03.17    (604.0, inf]       16       73       16       73   \n",
       "45  2024.03.18~03.24    (0.0, 521.0]        0        2        0        2   \n",
       "46  2024.03.18~03.24  (521.0, 542.0]        2        3        2        3   \n",
       "47  2024.03.18~03.24  (542.0, 576.0]       48      103       47      103   \n",
       "48  2024.03.18~03.24  (576.0, 604.0]        7       39        7       39   \n",
       "49  2024.03.18~03.24    (604.0, inf]        9       16        9       16   \n",
       "\n",
       "         pd1       cpd  \n",
       "0   0.603175  0.555556  \n",
       "1   0.591549  0.549296  \n",
       "2   0.440722  0.414948  \n",
       "3   0.341637  0.309609  \n",
       "4   0.308824  0.294118  \n",
       "5   0.600000  0.541667  \n",
       "6   0.491803  0.483607  \n",
       "7   0.441349  0.416422  \n",
       "8   0.395294  0.371765  \n",
       "9   0.357664  0.335766  \n",
       "10  0.363636  0.363636  \n",
       "11  0.500000  0.500000  \n",
       "12  0.490291  0.446602  \n",
       "13  0.437158  0.396175  \n",
       "14  0.384615  0.346154  \n",
       "15  1.000000  1.000000  \n",
       "16       NaN       NaN  \n",
       "17  0.300000  0.200000  \n",
       "18  0.468665  0.427793  \n",
       "19  0.389831  0.338983  \n",
       "20       NaN       NaN  \n",
       "21       NaN       NaN  \n",
       "22  0.000000  0.000000  \n",
       "23  0.508523  0.468750  \n",
       "24  0.343137  0.284314  \n",
       "25       NaN       NaN  \n",
       "26       NaN       NaN  \n",
       "27  0.000000  0.000000  \n",
       "28  0.489676  0.460177  \n",
       "29  0.456897  0.405172  \n",
       "30  0.454545  0.436364  \n",
       "31  0.516304  0.500000  \n",
       "32  0.451550  0.422481  \n",
       "33  0.490323  0.441935  \n",
       "34  0.322917  0.302083  \n",
       "35  0.409091  0.363636  \n",
       "36  0.347826  0.347826  \n",
       "37  0.530120  0.500000  \n",
       "38  0.471338  0.445860  \n",
       "39  0.300000  0.300000  \n",
       "40  0.375000  0.250000  \n",
       "41  0.600000  0.566667  \n",
       "42  0.498471  0.480122  \n",
       "43  0.412903  0.380645  \n",
       "44  0.219178  0.219178  \n",
       "45  0.000000  0.000000  \n",
       "46  0.666667  0.666667  \n",
       "47  0.466019  0.456311  \n",
       "48  0.179487  0.179487  \n",
       "49  0.562500  0.562500  "
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']==0)&(df['scorev8']>0) \n",
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev8_bin']\n",
    "df['scorev8_bin'] = pd.cut(df['scorev8'],[0,521,542,576,604,np.inf])\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "41262e26",
   "metadata": {},
   "source": [
    "# scorev9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "9ca2b5ff",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:48:47.214686Z",
     "start_time": "2024-03-20T06:48:47.150324Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev9_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 521.0]</td>\n",
       "      <td>306</td>\n",
       "      <td>335</td>\n",
       "      <td>641</td>\n",
       "      <td>0.090935</td>\n",
       "      <td>0.522621</td>\n",
       "      <td>-0.290347</td>\n",
       "      <td>1.162865</td>\n",
       "      <td>0.026899</td>\n",
       "      <td>0.031592</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev9_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>657</td>\n",
       "      <td>583</td>\n",
       "      <td>1240</td>\n",
       "      <td>0.175911</td>\n",
       "      <td>0.470161</td>\n",
       "      <td>-0.083025</td>\n",
       "      <td>1.046139</td>\n",
       "      <td>0.041641</td>\n",
       "      <td>0.031592</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev9_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(542.0, 573.0]</td>\n",
       "      <td>1311</td>\n",
       "      <td>1163</td>\n",
       "      <td>2474</td>\n",
       "      <td>0.350972</td>\n",
       "      <td>0.470089</td>\n",
       "      <td>-0.082969</td>\n",
       "      <td>1.045978</td>\n",
       "      <td>0.070950</td>\n",
       "      <td>0.031592</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev9_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(573.0, 590.0]</td>\n",
       "      <td>849</td>\n",
       "      <td>626</td>\n",
       "      <td>1475</td>\n",
       "      <td>0.209250</td>\n",
       "      <td>0.424407</td>\n",
       "      <td>0.101229</td>\n",
       "      <td>0.944332</td>\n",
       "      <td>0.049793</td>\n",
       "      <td>0.031592</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>scorev9_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(590.0, 604.0]</td>\n",
       "      <td>428</td>\n",
       "      <td>293</td>\n",
       "      <td>721</td>\n",
       "      <td>0.102284</td>\n",
       "      <td>0.406380</td>\n",
       "      <td>0.174231</td>\n",
       "      <td>0.904221</td>\n",
       "      <td>0.031999</td>\n",
       "      <td>0.031592</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>scorev9_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>330</td>\n",
       "      <td>168</td>\n",
       "      <td>498</td>\n",
       "      <td>0.070648</td>\n",
       "      <td>0.337349</td>\n",
       "      <td>0.465147</td>\n",
       "      <td>0.750624</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.031592</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           var   target             bin  negative  positive  total  \\\n",
       "0  scorev9_bin  def_pd1   (-inf, 521.0]       306       335    641   \n",
       "1  scorev9_bin  def_pd1  (521.0, 542.0]       657       583   1240   \n",
       "2  scorev9_bin  def_pd1  (542.0, 573.0]      1311      1163   2474   \n",
       "3  scorev9_bin  def_pd1  (573.0, 590.0]       849       626   1475   \n",
       "4  scorev9_bin  def_pd1  (590.0, 604.0]       428       293    721   \n",
       "5  scorev9_bin  def_pd1    (604.0, inf]       330       168    498   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.090935       0.522621 -0.290347  1.162865  0.026899  0.031592  \n",
       "1    0.175911       0.470161 -0.083025  1.046139  0.041641  0.031592  \n",
       "2    0.350972       0.470089 -0.082969  1.045978  0.070950  0.031592  \n",
       "3    0.209250       0.424407  0.101229  0.944332  0.049793  0.031592  \n",
       "4    0.102284       0.406380  0.174231  0.904221  0.031999  0.031592  \n",
       "5    0.070648       0.337349  0.465147  0.750624  0.000000  0.031592  "
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']==0)&(df['scorev9']>0)\n",
    "df['scorev9_bin'] = pd.cut(df['scorev9'],[-np.inf,521,542,573,590,604,np.inf])\n",
    "kit.univerate(df[condition],'scorev9_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "ea83dce3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:49:14.081343Z",
     "start_time": "2024-03-20T06:49:14.022969Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_27965/1208034288.py:63: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.\n",
      "  grouped = data.groupby(group)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>repayment_week</th>\n",
       "      <th>scorev9_bin</th>\n",
       "      <th>def_pd1</th>\n",
       "      <th>agr_pd1</th>\n",
       "      <th>def_cpd</th>\n",
       "      <th>agr_cpd</th>\n",
       "      <th>pd1</th>\n",
       "      <th>cpd</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(-inf, 521.0]</td>\n",
       "      <td>37</td>\n",
       "      <td>65</td>\n",
       "      <td>35</td>\n",
       "      <td>65</td>\n",
       "      <td>0.569231</td>\n",
       "      <td>0.538462</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>76</td>\n",
       "      <td>146</td>\n",
       "      <td>71</td>\n",
       "      <td>146</td>\n",
       "      <td>0.520548</td>\n",
       "      <td>0.486301</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(542.0, 573.0]</td>\n",
       "      <td>179</td>\n",
       "      <td>407</td>\n",
       "      <td>166</td>\n",
       "      <td>407</td>\n",
       "      <td>0.439803</td>\n",
       "      <td>0.407862</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(573.0, 590.0]</td>\n",
       "      <td>75</td>\n",
       "      <td>191</td>\n",
       "      <td>69</td>\n",
       "      <td>191</td>\n",
       "      <td>0.392670</td>\n",
       "      <td>0.361257</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(590.0, 604.0]</td>\n",
       "      <td>24</td>\n",
       "      <td>66</td>\n",
       "      <td>22</td>\n",
       "      <td>66</td>\n",
       "      <td>0.363636</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2024.01.15~01.21</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>19</td>\n",
       "      <td>67</td>\n",
       "      <td>18</td>\n",
       "      <td>67</td>\n",
       "      <td>0.283582</td>\n",
       "      <td>0.268657</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(-inf, 521.0]</td>\n",
       "      <td>88</td>\n",
       "      <td>148</td>\n",
       "      <td>84</td>\n",
       "      <td>148</td>\n",
       "      <td>0.594595</td>\n",
       "      <td>0.567568</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>140</td>\n",
       "      <td>277</td>\n",
       "      <td>131</td>\n",
       "      <td>277</td>\n",
       "      <td>0.505415</td>\n",
       "      <td>0.472924</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(542.0, 573.0]</td>\n",
       "      <td>326</td>\n",
       "      <td>721</td>\n",
       "      <td>311</td>\n",
       "      <td>721</td>\n",
       "      <td>0.452150</td>\n",
       "      <td>0.431345</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(573.0, 590.0]</td>\n",
       "      <td>99</td>\n",
       "      <td>286</td>\n",
       "      <td>90</td>\n",
       "      <td>286</td>\n",
       "      <td>0.346154</td>\n",
       "      <td>0.314685</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(590.0, 604.0]</td>\n",
       "      <td>35</td>\n",
       "      <td>106</td>\n",
       "      <td>33</td>\n",
       "      <td>106</td>\n",
       "      <td>0.330189</td>\n",
       "      <td>0.311321</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2024.01.22~01.28</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>22</td>\n",
       "      <td>70</td>\n",
       "      <td>22</td>\n",
       "      <td>70</td>\n",
       "      <td>0.314286</td>\n",
       "      <td>0.314286</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(-inf, 521.0]</td>\n",
       "      <td>11</td>\n",
       "      <td>28</td>\n",
       "      <td>11</td>\n",
       "      <td>28</td>\n",
       "      <td>0.392857</td>\n",
       "      <td>0.392857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>35</td>\n",
       "      <td>76</td>\n",
       "      <td>34</td>\n",
       "      <td>76</td>\n",
       "      <td>0.460526</td>\n",
       "      <td>0.447368</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(542.0, 573.0]</td>\n",
       "      <td>129</td>\n",
       "      <td>294</td>\n",
       "      <td>112</td>\n",
       "      <td>294</td>\n",
       "      <td>0.438776</td>\n",
       "      <td>0.380952</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(573.0, 590.0]</td>\n",
       "      <td>88</td>\n",
       "      <td>179</td>\n",
       "      <td>83</td>\n",
       "      <td>179</td>\n",
       "      <td>0.491620</td>\n",
       "      <td>0.463687</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(590.0, 604.0]</td>\n",
       "      <td>43</td>\n",
       "      <td>90</td>\n",
       "      <td>39</td>\n",
       "      <td>90</td>\n",
       "      <td>0.477778</td>\n",
       "      <td>0.433333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2024.01.29~02.04</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>16</td>\n",
       "      <td>54</td>\n",
       "      <td>15</td>\n",
       "      <td>54</td>\n",
       "      <td>0.296296</td>\n",
       "      <td>0.277778</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(-inf, 521.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(542.0, 573.0]</td>\n",
       "      <td>80</td>\n",
       "      <td>163</td>\n",
       "      <td>74</td>\n",
       "      <td>163</td>\n",
       "      <td>0.490798</td>\n",
       "      <td>0.453988</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(573.0, 590.0]</td>\n",
       "      <td>75</td>\n",
       "      <td>167</td>\n",
       "      <td>67</td>\n",
       "      <td>167</td>\n",
       "      <td>0.449102</td>\n",
       "      <td>0.401198</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(590.0, 604.0]</td>\n",
       "      <td>40</td>\n",
       "      <td>96</td>\n",
       "      <td>35</td>\n",
       "      <td>96</td>\n",
       "      <td>0.416667</td>\n",
       "      <td>0.364583</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2024.02.05~02.11</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>23</td>\n",
       "      <td>62</td>\n",
       "      <td>21</td>\n",
       "      <td>62</td>\n",
       "      <td>0.370968</td>\n",
       "      <td>0.338710</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(-inf, 521.0]</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>6</td>\n",
       "      <td>13</td>\n",
       "      <td>5</td>\n",
       "      <td>13</td>\n",
       "      <td>0.461538</td>\n",
       "      <td>0.384615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(542.0, 573.0]</td>\n",
       "      <td>81</td>\n",
       "      <td>138</td>\n",
       "      <td>75</td>\n",
       "      <td>138</td>\n",
       "      <td>0.586957</td>\n",
       "      <td>0.543478</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(573.0, 590.0]</td>\n",
       "      <td>57</td>\n",
       "      <td>141</td>\n",
       "      <td>51</td>\n",
       "      <td>141</td>\n",
       "      <td>0.404255</td>\n",
       "      <td>0.361702</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(590.0, 604.0]</td>\n",
       "      <td>50</td>\n",
       "      <td>98</td>\n",
       "      <td>47</td>\n",
       "      <td>98</td>\n",
       "      <td>0.510204</td>\n",
       "      <td>0.479592</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2024.02.12~02.18</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>20</td>\n",
       "      <td>65</td>\n",
       "      <td>16</td>\n",
       "      <td>65</td>\n",
       "      <td>0.307692</td>\n",
       "      <td>0.246154</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(-inf, 521.0]</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>8</td>\n",
       "      <td>16</td>\n",
       "      <td>8</td>\n",
       "      <td>16</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(542.0, 573.0]</td>\n",
       "      <td>75</td>\n",
       "      <td>137</td>\n",
       "      <td>71</td>\n",
       "      <td>137</td>\n",
       "      <td>0.547445</td>\n",
       "      <td>0.518248</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(573.0, 590.0]</td>\n",
       "      <td>80</td>\n",
       "      <td>161</td>\n",
       "      <td>72</td>\n",
       "      <td>161</td>\n",
       "      <td>0.496894</td>\n",
       "      <td>0.447205</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(590.0, 604.0]</td>\n",
       "      <td>30</td>\n",
       "      <td>76</td>\n",
       "      <td>28</td>\n",
       "      <td>76</td>\n",
       "      <td>0.394737</td>\n",
       "      <td>0.368421</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2024.02.19~02.25</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>25</td>\n",
       "      <td>66</td>\n",
       "      <td>24</td>\n",
       "      <td>66</td>\n",
       "      <td>0.378788</td>\n",
       "      <td>0.363636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(-inf, 521.0]</td>\n",
       "      <td>146</td>\n",
       "      <td>292</td>\n",
       "      <td>142</td>\n",
       "      <td>292</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.486301</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>180</td>\n",
       "      <td>405</td>\n",
       "      <td>167</td>\n",
       "      <td>405</td>\n",
       "      <td>0.444444</td>\n",
       "      <td>0.412346</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(542.0, 573.0]</td>\n",
       "      <td>99</td>\n",
       "      <td>206</td>\n",
       "      <td>93</td>\n",
       "      <td>206</td>\n",
       "      <td>0.480583</td>\n",
       "      <td>0.451456</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(573.0, 590.0]</td>\n",
       "      <td>60</td>\n",
       "      <td>140</td>\n",
       "      <td>55</td>\n",
       "      <td>140</td>\n",
       "      <td>0.428571</td>\n",
       "      <td>0.392857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(590.0, 604.0]</td>\n",
       "      <td>36</td>\n",
       "      <td>82</td>\n",
       "      <td>31</td>\n",
       "      <td>82</td>\n",
       "      <td>0.439024</td>\n",
       "      <td>0.378049</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>2024.02.26~03.03</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>15</td>\n",
       "      <td>36</td>\n",
       "      <td>12</td>\n",
       "      <td>36</td>\n",
       "      <td>0.416667</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(-inf, 521.0]</td>\n",
       "      <td>19</td>\n",
       "      <td>46</td>\n",
       "      <td>18</td>\n",
       "      <td>46</td>\n",
       "      <td>0.413043</td>\n",
       "      <td>0.391304</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>40</td>\n",
       "      <td>81</td>\n",
       "      <td>38</td>\n",
       "      <td>81</td>\n",
       "      <td>0.493827</td>\n",
       "      <td>0.469136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(542.0, 573.0]</td>\n",
       "      <td>77</td>\n",
       "      <td>155</td>\n",
       "      <td>75</td>\n",
       "      <td>155</td>\n",
       "      <td>0.496774</td>\n",
       "      <td>0.483871</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(573.0, 590.0]</td>\n",
       "      <td>41</td>\n",
       "      <td>93</td>\n",
       "      <td>37</td>\n",
       "      <td>93</td>\n",
       "      <td>0.440860</td>\n",
       "      <td>0.397849</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(590.0, 604.0]</td>\n",
       "      <td>13</td>\n",
       "      <td>41</td>\n",
       "      <td>12</td>\n",
       "      <td>41</td>\n",
       "      <td>0.317073</td>\n",
       "      <td>0.292683</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>2024.03.04~03.10</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>15</td>\n",
       "      <td>35</td>\n",
       "      <td>15</td>\n",
       "      <td>35</td>\n",
       "      <td>0.428571</td>\n",
       "      <td>0.428571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(-inf, 521.0]</td>\n",
       "      <td>28</td>\n",
       "      <td>49</td>\n",
       "      <td>24</td>\n",
       "      <td>49</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.489796</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>69</td>\n",
       "      <td>167</td>\n",
       "      <td>67</td>\n",
       "      <td>167</td>\n",
       "      <td>0.413174</td>\n",
       "      <td>0.401198</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(542.0, 573.0]</td>\n",
       "      <td>96</td>\n",
       "      <td>199</td>\n",
       "      <td>91</td>\n",
       "      <td>199</td>\n",
       "      <td>0.482412</td>\n",
       "      <td>0.457286</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(573.0, 590.0]</td>\n",
       "      <td>42</td>\n",
       "      <td>93</td>\n",
       "      <td>41</td>\n",
       "      <td>93</td>\n",
       "      <td>0.451613</td>\n",
       "      <td>0.440860</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(590.0, 604.0]</td>\n",
       "      <td>18</td>\n",
       "      <td>52</td>\n",
       "      <td>17</td>\n",
       "      <td>52</td>\n",
       "      <td>0.346154</td>\n",
       "      <td>0.326923</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>2024.03.11~03.17</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>11</td>\n",
       "      <td>33</td>\n",
       "      <td>11</td>\n",
       "      <td>33</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(-inf, 521.0]</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>0.375000</td>\n",
       "      <td>0.375000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(521.0, 542.0]</td>\n",
       "      <td>27</td>\n",
       "      <td>53</td>\n",
       "      <td>27</td>\n",
       "      <td>53</td>\n",
       "      <td>0.509434</td>\n",
       "      <td>0.509434</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(542.0, 573.0]</td>\n",
       "      <td>21</td>\n",
       "      <td>54</td>\n",
       "      <td>20</td>\n",
       "      <td>54</td>\n",
       "      <td>0.388889</td>\n",
       "      <td>0.370370</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(573.0, 590.0]</td>\n",
       "      <td>9</td>\n",
       "      <td>24</td>\n",
       "      <td>9</td>\n",
       "      <td>24</td>\n",
       "      <td>0.375000</td>\n",
       "      <td>0.375000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(590.0, 604.0]</td>\n",
       "      <td>4</td>\n",
       "      <td>14</td>\n",
       "      <td>4</td>\n",
       "      <td>14</td>\n",
       "      <td>0.285714</td>\n",
       "      <td>0.285714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>2024.03.18~03.24</td>\n",
       "      <td>(604.0, inf]</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.200000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      repayment_week     scorev9_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n",
       "0   2024.01.15~01.21   (-inf, 521.0]       37       65       35       65   \n",
       "1   2024.01.15~01.21  (521.0, 542.0]       76      146       71      146   \n",
       "2   2024.01.15~01.21  (542.0, 573.0]      179      407      166      407   \n",
       "3   2024.01.15~01.21  (573.0, 590.0]       75      191       69      191   \n",
       "4   2024.01.15~01.21  (590.0, 604.0]       24       66       22       66   \n",
       "5   2024.01.15~01.21    (604.0, inf]       19       67       18       67   \n",
       "6   2024.01.22~01.28   (-inf, 521.0]       88      148       84      148   \n",
       "7   2024.01.22~01.28  (521.0, 542.0]      140      277      131      277   \n",
       "8   2024.01.22~01.28  (542.0, 573.0]      326      721      311      721   \n",
       "9   2024.01.22~01.28  (573.0, 590.0]       99      286       90      286   \n",
       "10  2024.01.22~01.28  (590.0, 604.0]       35      106       33      106   \n",
       "11  2024.01.22~01.28    (604.0, inf]       22       70       22       70   \n",
       "12  2024.01.29~02.04   (-inf, 521.0]       11       28       11       28   \n",
       "13  2024.01.29~02.04  (521.0, 542.0]       35       76       34       76   \n",
       "14  2024.01.29~02.04  (542.0, 573.0]      129      294      112      294   \n",
       "15  2024.01.29~02.04  (573.0, 590.0]       88      179       83      179   \n",
       "16  2024.01.29~02.04  (590.0, 604.0]       43       90       39       90   \n",
       "17  2024.01.29~02.04    (604.0, inf]       16       54       15       54   \n",
       "18  2024.02.05~02.11   (-inf, 521.0]        2        2        1        2   \n",
       "19  2024.02.05~02.11  (521.0, 542.0]        2        6        2        6   \n",
       "20  2024.02.05~02.11  (542.0, 573.0]       80      163       74      163   \n",
       "21  2024.02.05~02.11  (573.0, 590.0]       75      167       67      167   \n",
       "22  2024.02.05~02.11  (590.0, 604.0]       40       96       35       96   \n",
       "23  2024.02.05~02.11    (604.0, inf]       23       62       21       62   \n",
       "24  2024.02.12~02.18   (-inf, 521.0]        0        1        0        1   \n",
       "25  2024.02.12~02.18  (521.0, 542.0]        6       13        5       13   \n",
       "26  2024.02.12~02.18  (542.0, 573.0]       81      138       75      138   \n",
       "27  2024.02.12~02.18  (573.0, 590.0]       57      141       51      141   \n",
       "28  2024.02.12~02.18  (590.0, 604.0]       50       98       47       98   \n",
       "29  2024.02.12~02.18    (604.0, inf]       20       65       16       65   \n",
       "30  2024.02.19~02.25   (-inf, 521.0]        1        2        0        2   \n",
       "31  2024.02.19~02.25  (521.0, 542.0]        8       16        8       16   \n",
       "32  2024.02.19~02.25  (542.0, 573.0]       75      137       71      137   \n",
       "33  2024.02.19~02.25  (573.0, 590.0]       80      161       72      161   \n",
       "34  2024.02.19~02.25  (590.0, 604.0]       30       76       28       76   \n",
       "35  2024.02.19~02.25    (604.0, inf]       25       66       24       66   \n",
       "36  2024.02.26~03.03   (-inf, 521.0]      146      292      142      292   \n",
       "37  2024.02.26~03.03  (521.0, 542.0]      180      405      167      405   \n",
       "38  2024.02.26~03.03  (542.0, 573.0]       99      206       93      206   \n",
       "39  2024.02.26~03.03  (573.0, 590.0]       60      140       55      140   \n",
       "40  2024.02.26~03.03  (590.0, 604.0]       36       82       31       82   \n",
       "41  2024.02.26~03.03    (604.0, inf]       15       36       12       36   \n",
       "42  2024.03.04~03.10   (-inf, 521.0]       19       46       18       46   \n",
       "43  2024.03.04~03.10  (521.0, 542.0]       40       81       38       81   \n",
       "44  2024.03.04~03.10  (542.0, 573.0]       77      155       75      155   \n",
       "45  2024.03.04~03.10  (573.0, 590.0]       41       93       37       93   \n",
       "46  2024.03.04~03.10  (590.0, 604.0]       13       41       12       41   \n",
       "47  2024.03.04~03.10    (604.0, inf]       15       35       15       35   \n",
       "48  2024.03.11~03.17   (-inf, 521.0]       28       49       24       49   \n",
       "49  2024.03.11~03.17  (521.0, 542.0]       69      167       67      167   \n",
       "50  2024.03.11~03.17  (542.0, 573.0]       96      199       91      199   \n",
       "51  2024.03.11~03.17  (573.0, 590.0]       42       93       41       93   \n",
       "52  2024.03.11~03.17  (590.0, 604.0]       18       52       17       52   \n",
       "53  2024.03.11~03.17    (604.0, inf]       11       33       11       33   \n",
       "54  2024.03.18~03.24   (-inf, 521.0]        3        8        3        8   \n",
       "55  2024.03.18~03.24  (521.0, 542.0]       27       53       27       53   \n",
       "56  2024.03.18~03.24  (542.0, 573.0]       21       54       20       54   \n",
       "57  2024.03.18~03.24  (573.0, 590.0]        9       24        9       24   \n",
       "58  2024.03.18~03.24  (590.0, 604.0]        4       14        4       14   \n",
       "59  2024.03.18~03.24    (604.0, inf]        2       10        2       10   \n",
       "\n",
       "         pd1       cpd  \n",
       "0   0.569231  0.538462  \n",
       "1   0.520548  0.486301  \n",
       "2   0.439803  0.407862  \n",
       "3   0.392670  0.361257  \n",
       "4   0.363636  0.333333  \n",
       "5   0.283582  0.268657  \n",
       "6   0.594595  0.567568  \n",
       "7   0.505415  0.472924  \n",
       "8   0.452150  0.431345  \n",
       "9   0.346154  0.314685  \n",
       "10  0.330189  0.311321  \n",
       "11  0.314286  0.314286  \n",
       "12  0.392857  0.392857  \n",
       "13  0.460526  0.447368  \n",
       "14  0.438776  0.380952  \n",
       "15  0.491620  0.463687  \n",
       "16  0.477778  0.433333  \n",
       "17  0.296296  0.277778  \n",
       "18  1.000000  0.500000  \n",
       "19  0.333333  0.333333  \n",
       "20  0.490798  0.453988  \n",
       "21  0.449102  0.401198  \n",
       "22  0.416667  0.364583  \n",
       "23  0.370968  0.338710  \n",
       "24  0.000000  0.000000  \n",
       "25  0.461538  0.384615  \n",
       "26  0.586957  0.543478  \n",
       "27  0.404255  0.361702  \n",
       "28  0.510204  0.479592  \n",
       "29  0.307692  0.246154  \n",
       "30  0.500000  0.000000  \n",
       "31  0.500000  0.500000  \n",
       "32  0.547445  0.518248  \n",
       "33  0.496894  0.447205  \n",
       "34  0.394737  0.368421  \n",
       "35  0.378788  0.363636  \n",
       "36  0.500000  0.486301  \n",
       "37  0.444444  0.412346  \n",
       "38  0.480583  0.451456  \n",
       "39  0.428571  0.392857  \n",
       "40  0.439024  0.378049  \n",
       "41  0.416667  0.333333  \n",
       "42  0.413043  0.391304  \n",
       "43  0.493827  0.469136  \n",
       "44  0.496774  0.483871  \n",
       "45  0.440860  0.397849  \n",
       "46  0.317073  0.292683  \n",
       "47  0.428571  0.428571  \n",
       "48  0.571429  0.489796  \n",
       "49  0.413174  0.401198  \n",
       "50  0.482412  0.457286  \n",
       "51  0.451613  0.440860  \n",
       "52  0.346154  0.326923  \n",
       "53  0.333333  0.333333  \n",
       "54  0.375000  0.375000  \n",
       "55  0.509434  0.509434  \n",
       "56  0.388889  0.370370  \n",
       "57  0.375000  0.375000  \n",
       "58  0.285714  0.285714  \n",
       "59  0.200000  0.200000  "
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']==0)&(df['scorev9']>0)\n",
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "df['scorev9_bin'] = pd.cut(df['scorev9'],[-np.inf,521,542,573,590,604,np.inf])\n",
    "group=['repayment_week','scorev9_bin']\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "76d8c697805dc093",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-06T01:54:05.228374Z",
     "start_time": "2024-02-06T01:54:04.502802Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.23076923076923078"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3/(1+4+8)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eb4e96866b414dba",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "# scorev10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "82976438c175092c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T06:49:59.380603Z",
     "start_time": "2024-03-20T06:49:59.319899Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev10_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 530.0]</td>\n",
       "      <td>88</td>\n",
       "      <td>61</td>\n",
       "      <td>149</td>\n",
       "      <td>0.033995</td>\n",
       "      <td>0.409396</td>\n",
       "      <td>-0.269111</td>\n",
       "      <td>1.188333</td>\n",
       "      <td>0.009767</td>\n",
       "      <td>0.02147</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev10_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(530.0, 580.0]</td>\n",
       "      <td>1547</td>\n",
       "      <td>895</td>\n",
       "      <td>2442</td>\n",
       "      <td>0.557153</td>\n",
       "      <td>0.366503</td>\n",
       "      <td>-0.095828</td>\n",
       "      <td>1.063829</td>\n",
       "      <td>0.064021</td>\n",
       "      <td>0.02147</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev10_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(580.0, 590.0]</td>\n",
       "      <td>899</td>\n",
       "      <td>379</td>\n",
       "      <td>1278</td>\n",
       "      <td>0.291581</td>\n",
       "      <td>0.296557</td>\n",
       "      <td>0.219714</td>\n",
       "      <td>0.860801</td>\n",
       "      <td>0.002101</td>\n",
       "      <td>0.02147</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev10_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(590.0, inf]</td>\n",
       "      <td>339</td>\n",
       "      <td>175</td>\n",
       "      <td>514</td>\n",
       "      <td>0.117271</td>\n",
       "      <td>0.340467</td>\n",
       "      <td>0.017815</td>\n",
       "      <td>0.988256</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.02147</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            var   target             bin  negative  positive  total  \\\n",
       "0  scorev10_bin  def_pd1   (-inf, 530.0]        88        61    149   \n",
       "1  scorev10_bin  def_pd1  (530.0, 580.0]      1547       895   2442   \n",
       "2  scorev10_bin  def_pd1  (580.0, 590.0]       899       379   1278   \n",
       "3  scorev10_bin  def_pd1    (590.0, inf]       339       175    514   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS       IV  \n",
       "0    0.033995       0.409396 -0.269111  1.188333  0.009767  0.02147  \n",
       "1    0.557153       0.366503 -0.095828  1.063829  0.064021  0.02147  \n",
       "2    0.291581       0.296557  0.219714  0.860801  0.002101  0.02147  \n",
       "3    0.117271       0.340467  0.017815  0.988256  0.000000  0.02147  "
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']>0)&(df['scorev10']>0) & (df['apply_time']>=pd.to_datetime(\"2024-02-07\"))\n",
    "df['scorev10_bin'] = pd.cut(df['scorev10'],[-np.inf,530,580,590,np.inf ])\n",
    "kit.univerate(df[condition],'scorev10_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9228b16c24ff9a1e",
   "metadata": {
    "collapsed": false,
    "is_executing": true
   },
   "outputs": [],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev10_bin']\n",
    "kit.group_rs(df[condition],group,sum_col,None,rate_tupes)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2f1c544f8c5f9f64",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "# scorev11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "cc6ed1b6e069c2f7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T07:04:33.029272Z",
     "start_time": "2024-03-20T07:04:32.968158Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev11_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 619.0]</td>\n",
       "      <td>1016</td>\n",
       "      <td>652</td>\n",
       "      <td>1668</td>\n",
       "      <td>0.491456</td>\n",
       "      <td>0.390887</td>\n",
       "      <td>-0.308340</td>\n",
       "      <td>1.220489</td>\n",
       "      <td>0.159417</td>\n",
       "      <td>0.151371</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev11_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(619.0, 628.0]</td>\n",
       "      <td>498</td>\n",
       "      <td>237</td>\n",
       "      <td>735</td>\n",
       "      <td>0.216559</td>\n",
       "      <td>0.322449</td>\n",
       "      <td>-0.009941</td>\n",
       "      <td>1.006800</td>\n",
       "      <td>0.161584</td>\n",
       "      <td>0.151371</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev11_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(628.0, inf]</td>\n",
       "      <td>793</td>\n",
       "      <td>198</td>\n",
       "      <td>991</td>\n",
       "      <td>0.291986</td>\n",
       "      <td>0.199798</td>\n",
       "      <td>0.632460</td>\n",
       "      <td>0.623841</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.151371</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            var   target             bin  negative  positive  total  \\\n",
       "0  scorev11_bin  def_pd1   (-inf, 619.0]      1016       652   1668   \n",
       "1  scorev11_bin  def_pd1  (619.0, 628.0]       498       237    735   \n",
       "2  scorev11_bin  def_pd1    (628.0, inf]       793       198    991   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.491456       0.390887 -0.308340  1.220489  0.159417  0.151371  \n",
       "1    0.216559       0.322449 -0.009941  1.006800  0.161584  0.151371  \n",
       "2    0.291986       0.199798  0.632460  0.623841  0.000000  0.151371  "
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']>=1) & (df['scorev11']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-03-04\"))\n",
    "df['scorev11_bin'] = pd.cut(df['scorev11'],[-np.inf,619,628,np.inf])\n",
    "kit.univerate(df[condition],'scorev11_bin','def_pd1')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f7a628618c5842ed",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "# scorev12"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "8beee3c71cf29f40",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-20T07:12:51.706354Z",
     "start_time": "2024-03-20T07:12:51.647197Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "      <th>target</th>\n",
       "      <th>bin</th>\n",
       "      <th>negative</th>\n",
       "      <th>positive</th>\n",
       "      <th>total</th>\n",
       "      <th>total_rate</th>\n",
       "      <th>positive_rate</th>\n",
       "      <th>woe</th>\n",
       "      <th>LIFT</th>\n",
       "      <th>KS</th>\n",
       "      <th>IV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>scorev12_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(-inf, 520.0]</td>\n",
       "      <td>77</td>\n",
       "      <td>89</td>\n",
       "      <td>166</td>\n",
       "      <td>0.054749</td>\n",
       "      <td>0.536145</td>\n",
       "      <td>-0.716687</td>\n",
       "      <td>1.498240</td>\n",
       "      <td>0.042480</td>\n",
       "      <td>0.297976</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>scorev12_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(520.0, 558.0]</td>\n",
       "      <td>302</td>\n",
       "      <td>283</td>\n",
       "      <td>585</td>\n",
       "      <td>0.192942</td>\n",
       "      <td>0.483761</td>\n",
       "      <td>-0.517130</td>\n",
       "      <td>1.351855</td>\n",
       "      <td>0.148199</td>\n",
       "      <td>0.297976</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>scorev12_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(558.0, 620.0]</td>\n",
       "      <td>862</td>\n",
       "      <td>537</td>\n",
       "      <td>1399</td>\n",
       "      <td>0.461412</td>\n",
       "      <td>0.383846</td>\n",
       "      <td>-0.111215</td>\n",
       "      <td>1.072645</td>\n",
       "      <td>0.200397</td>\n",
       "      <td>0.297976</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>scorev12_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(620.0, 635.0]</td>\n",
       "      <td>132</td>\n",
       "      <td>65</td>\n",
       "      <td>197</td>\n",
       "      <td>0.064974</td>\n",
       "      <td>0.329949</td>\n",
       "      <td>0.121793</td>\n",
       "      <td>0.922033</td>\n",
       "      <td>0.192508</td>\n",
       "      <td>0.297976</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>scorev12_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(635.0, 650.0]</td>\n",
       "      <td>210</td>\n",
       "      <td>49</td>\n",
       "      <td>259</td>\n",
       "      <td>0.085422</td>\n",
       "      <td>0.189189</td>\n",
       "      <td>0.857905</td>\n",
       "      <td>0.528684</td>\n",
       "      <td>0.129811</td>\n",
       "      <td>0.297976</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>scorev12_bin</td>\n",
       "      <td>def_pd1</td>\n",
       "      <td>(650.0, inf]</td>\n",
       "      <td>364</td>\n",
       "      <td>62</td>\n",
       "      <td>426</td>\n",
       "      <td>0.140501</td>\n",
       "      <td>0.145540</td>\n",
       "      <td>1.173296</td>\n",
       "      <td>0.406707</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.297976</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            var   target             bin  negative  positive  total  \\\n",
       "0  scorev12_bin  def_pd1   (-inf, 520.0]        77        89    166   \n",
       "1  scorev12_bin  def_pd1  (520.0, 558.0]       302       283    585   \n",
       "2  scorev12_bin  def_pd1  (558.0, 620.0]       862       537   1399   \n",
       "3  scorev12_bin  def_pd1  (620.0, 635.0]       132        65    197   \n",
       "4  scorev12_bin  def_pd1  (635.0, 650.0]       210        49    259   \n",
       "5  scorev12_bin  def_pd1    (650.0, inf]       364        62    426   \n",
       "\n",
       "   total_rate  positive_rate       woe      LIFT        KS        IV  \n",
       "0    0.054749       0.536145 -0.716687  1.498240  0.042480  0.297976  \n",
       "1    0.192942       0.483761 -0.517130  1.351855  0.148199  0.297976  \n",
       "2    0.461412       0.383846 -0.111215  1.072645  0.200397  0.297976  \n",
       "3    0.064974       0.329949  0.121793  0.922033  0.192508  0.297976  \n",
       "4    0.085422       0.189189  0.857905  0.528684  0.129811  0.297976  \n",
       "5    0.140501       0.145540  1.173296  0.406707  0.000000  0.297976  "
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']>=0) & (df['scorev12']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-03-04\"))\n",
    "df['scorev12_bin'] = pd.cut(df['scorev12'],[-np.inf,520,558,620,635,650,np.inf])\n",
    "kit.univerate(df[condition],'scorev12_bin','def_pd1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ba957ceb5402ec92",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "384px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
